Does the input function always takes inputs as strings? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Does the input function always takes inputs as strings?

26th Jan 2020, 3:41 PM
Hzkel
Hzkel - avatar
2 Answers
+ 1
Yes, but you can convert it to other types if needed. For example, you can use int(input()) to convert input to an integer. input().split() will convert the input into a list, by spaces or any string you provide to it. There are a couple others.
26th Jan 2020, 4:26 PM
Jianmin Chen
Jianmin Chen - avatar
+ 5
Yes. https://docs.python.org/3/library/functions.html#input
26th Jan 2020, 3:43 PM
Hatsy Rei
Hatsy Rei - avatar