+ 1
How to get input like this in python?
Guys I have a problem in which The input is like 10 28 12 5 6 7 1 5 How do I get this as input and process this ? It's four points of a square and I'm gonna use distance between two points formula
4 Respuestas
+ 2
for i in range(0, 4):
num1 = int(input())
num2 = int(input())
# you can now use num1 and num2 to do any calculation
+ 2
a=[]
for i in range(4):
a.append(input().split())
+ 2
Here is a code that should do the job:
# assuming input will be: 1,2 3,4 5,6 7,8
inp = []
for i in range(4):
[inp.append(list(map(int, input(f'Enter {i+1} pair (sep by comma): ').split(','))))]
print(inp)
# output will be a list of lists (integer numbers):
# [[1, 2], [3, 4], [5, 6], [7, 8]]
# access the pairs with:
# for i in inp:
i[0] is first number, i[1] is second number
+ 1
Thanks