+ 1
Else statement not working Python
A part of the program tests if the variable is int or string. If it's a string do this, else do that. Even though I seperated them, it still runs the both statements. I entered a string, but it tries to loop over range(String) which causes error. Why won't the else statement work? Line 34 https://code.sololearn.com/crAWjqQy8qiF/?ref=app
1 Resposta
+ 5
Instead checking type(statement)=="str" ,check for the string the following way,
if isinstance(statement,str):