+ 2
Python int input
How can we get 2 seperate integers when they are given in a single line seperated by space using input() function Eg. 2 4 I want to take this input as a=2 and b=4
3 Respostas
+ 4
inp = input("").split(" ")
a = int(inp[0])
b = int(inp[1])
+ 2
a, b = list(map(int, input().split()))
+ 1
# First Step You Get (input) and (spilt) Number
# spilt() => Method Take (separator as string, maxsplit as int) and Put items in list[]
my_input = input("Enter Number: ").split()
# Second step my_input = ['number_1', 'number_2']
# You assign Two Number by Zero Index Based to Variables
a = int(my_input[0])
b = int(my_input[1])