+ 1

Why does this code return always false?

num=input("insert a number") print(isinstance(num, int))

21st Apr 2018, 5:48 PM
Guido Parlatore
Guido Parlatore - avatar
5 odpowiedzi
21st Apr 2018, 6:06 PM
cyk
cyk - avatar
+ 5
Because num is a string... input() gets the input as a string, always, even numbers... To turn the input into an int you will have to do: int(num).
21st Apr 2018, 5:53 PM
cyk
cyk - avatar
+ 2
Now the code gives me error after typing input https://code.sololearn.com/cQVoic03uJ6Z/?ref=app
21st Apr 2018, 6:03 PM
Guido Parlatore
Guido Parlatore - avatar
+ 2
Let's see the code. Can you post a link to it here?
21st Apr 2018, 6:04 PM
cyk
cyk - avatar
+ 2
Thank you
21st Apr 2018, 6:07 PM
Guido Parlatore
Guido Parlatore - avatar