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))
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.
+ 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
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 :)