How can I set each number from input to its own variable?
code:
import sys
for line in sys.stdin:
print(line)
input:
(25,6) (25,10)
I want
x1=25
y1=6
x2= 25
y2 =10
How can I set each number from input to its own variable?
code:
import sys
for line in sys.stdin:
print(line)
input:
(25,6) (25,10)
I want
x1=25
y1=6
x2= 25
y2 =10
You can use a regular expression to extract the numbers from the input.
for line in sys.stdin:
match = re.search(r'\((\d+),(\d+)\)\s*\((\d+),(\d+)\)', line)
if match:
x1, y1, x2, y2 = map(int, match.groups())