We can get 3 number from user like this
a = int(input())
b = int(input())
c = int(input())
Now how can we get 3 number from user in one line?
a , b , c = int(input())
I tried this but it's not ok
We can get 3 number from user like this
a = int(input())
b = int(input())
c = int(input())
Now how can we get 3 number from user in one line?
a , b , c = int(input())
I tried this but it's not ok
You can do like this:
a, b, c = input("Insert the 3 values: ").split()
print(f"a: {a}\nb: {b}\nc: {c}")
See this similar question for more details
If you're reading data from a .txt
file and you're wanting to map variables a, b, and c in one line.
Example:
inputFile = open("example.txt",r)
a, b = map(int, inputFile.readline().split())
try:
a,b,c = map(int,input('input').split())
print(a,b,c)
except:
print('input is no good')