0

I want to write a code to see if an input number is natural or not but it won't work can you tell me what am I doing wrong?

a=0 while True: a+=1 b=[a] c=input() print(c in b) #i also tried print([c] in b)

16th Apr 2020, 11:11 AM
amirhossein fazeli
1 Answer
+ 1
If you tried this code in the app, one problem is that you ask form input within a loop. SL app does not allow for this. Also be aware that input() will return a value in string format no matter what we type in. So you need to explicitly convert c to a numeric type. Another issue is that the while loop will run infinitely as there is not break condition specified.
16th Apr 2020, 2:41 PM
Lisa
Lisa - avatar