how to input x and y as much as you could?

Viewed 71

this is what I currently have

apparently with what I use I can put as many x and y as I possibly could. but I couldn't make it automatically print out as much as the x and y input. is there a way to do that?

2 Answers

If the numbers in the inputs are separated by spaces, you can try this:

s = input("Enter x: ")
a = input("Enter y: ")
s = [int(x) for x in s.split()]
a = [int(x) for x in a.split()]
for i in range(len(s)):
    print((s[i], a[i]))

If the numbers in the inputs are not separated by spaces, you can try this:

s = input("Enter x: ")
a = input("Enter y: ")
s = [int(x) for x in str(s)]
a = [int(x) for x in str(a)]
for i in range(len(s)):
    print((s[i], a[i]))

Assume l1 and l2 are the lists you want to print...

for x,y in zip(l1,l2):
    print((x, y))

So your code should look like this

s = input("Enter x: ")
a = input("Enter y: ")
s = [int(x) for x in s.split()]
a = [int(x) for x in s.split()]
for x, y in zip(s, a):
    print((x, y))
Related