How can i write the code for an if condition where i want to see if i can convert the type of an element in a list to int. If its possible, then if condition should be executed.Otherwise, it should go to else statement
For eg:
lst=['@','#','^','%','20']
''' Now i am going to iterate through the list and check if i can convert the elements to type int. If it can be converted then i know there is a number in the list and i do some operations on the number'''
for ele in lst:
if(type(int(ele)=='int'):
#do some operation on the number eg:20/2 and print the value
else:
continue
Please give me an idea as to how to write the if condition.
tryto convert the element to int and proceed if successful,exceptthat you do something else when that fails with aValueError.