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)
1 Respuesta
+ 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.