#lis1=[ int(x)if x.isdigit() else 0 for x in list_of_strings]
lis1=[]
lis1=x.split()
print(lis1)
flag=0
j=0
while(j in range(len(lis1))):
if(lis1[j].isdigit()):
flag==0
else:
flag==1
try:
if(int(lis1[j])):
lis1[j]=int(lis[j])
else:
flag==1
break
except:
print("Cannot convert to integer")
j+=1
print(lis1)
safe_int(x)
Explanation:
We are taking as an input a sentence, and then splitting it into various list items, and storing them in a list. Now we try to convert each item to integer and using try-except print the message cannot convert if its not possible or else converts it. As a check. enter 0 2 7 0 and also try Hello World.
To get a sense as to what they are doing. They have to draw frame after frame after frame. Go back and fix it up. It's easier to draw on paper than use a mouse.