How about,
if isinstance(x, int):
but a cleaner way would simply be
sum(z for z in y if isinstance(z, int))
More Related Contents:
- Python 2: Conditional statement behaviour of lists with greater/smaller [duplicate]
- Determine the type of an object?
- Change column type in pandas
- Immutable vs Mutable types
- How to check if string input is a number?
- Strings in a DataFrame, but dtype is object
- Store different datatypes in one NumPy array?
- Can pandas automatically read dates from a CSV file?
- List vs tuple, when to use each? [duplicate]
- Creating a new column based on if-elif-else condition
- Check if something is (not) in a list in Python
- How do I find numeric columns in Pandas?
- Replacing Numpy elements if condition is met
- Fastest way to convert a dict’s keys & values from `unicode` to `str`?
- Pandas select rows and columns based on boolean condition
- Complex numbers in python
- Conditional with statement in Python
- What does dtype=object mean while creating a numpy array?
- Python check for integer input
- What is dtype(‘O’), in pandas?
- Why does object.__new__ work differently in these three cases
- Too many if statements
- Type hinting in Python 2
- How to check if a variable is a function in Python?
- the bytes type in python 2.7 and PEP-358
- Python: Can a subclass of float take extra arguments in its constructor?
- Possible to enforce type hints?
- Identifying the data type of an input
- Do union types actually exist in python?
- Python Numpy Data Types Performance