Is it possible for the user to input multiple variables around strings (so they are there as they type). I want the user to input numbers x,y,u,v like
(x,y) to (u,v) where the brackets and commas are there to guide their input.
I hope it to be something (I know this code is wrong) like:
a1, a2, a3, a4 = raw_input("("+x1+", "+x2+") to ("+x3+", "+x4+")").split()
where the i'th a varaible take the value of the i'th x value.
Your code is not wrong.
It actually works:
However:
a1
,a2
,a3
,a4
) are strings.You can solve first problem with
map(int, ...)
this way:For the second problem, maybe you can surround the code with a
try: ... except: ...
, and also surround it with awhile True
such that until it gets an exception, it repeats it:Here I try to feed it some bad input, and finally a good input (it terminates when it gets good input):