0

please tell me ways to convert the input to int ?(other than the way which i used)

# taking two inputs at a time x, y = input("Enter a two value: ").split() print("Number of boys: ", int(x)) print("Number of girls: ", int(y))

8th Oct 2020, 5:15 PM
partha
partha - avatar
3 Respostas
+ 4
You don’t need to convert to ints just to print them. print(“Number of boys:”, x) will work just fine. Otherwise, you can make use of the map() method. x, y = map(int, input(“...”).split()) This will set x and y as ints.
8th Oct 2020, 5:17 PM
Russ
Russ - avatar
+ 2
I don't know which way you looking for. x = int(x) y = int(x) As far as I know there is no other way to convert str to int
8th Oct 2020, 5:20 PM
Shadoff
Shadoff - avatar
0
@Russ I was using input('...').split() in another program which needed the input as 'int' and thanks i was looking for that kind of one line method :)
8th Oct 2020, 5:48 PM
partha
partha - avatar