How to read a integer and character from a single line of input separated by space? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to read a integer and character from a single line of input separated by space?

15th Sep 2016, 2:06 PM
pratik pratyay
pratik pratyay - avatar
1 Answer
0
when you get input in python it is automatically a string. to get an integer from an input you have to convert it using int (). Since you want both an int and a string from the input, you can use the str.split () method to divide the string at the space, then you can check which input is an int and convert it. hope that helps, but feel free to ask a follow up!
15th Sep 2016, 4:04 PM
Luke Armstrong