i have done the following code in order to fill a tuple with user input and then add the elements of the tuple.For example giving as input 1,2 and 3,4 i have the tuple : ((1,2),(3,4)).Then i want to add 1+2 and 3+4.
This is the first part which works ok:
data=[]
mytuple=()
while True:
myinput=raw_input("Enter two integers: ")
if not myinput:
print("Finished")
break
else:
myinput.split(",")
data.append(myinput)
mytuple=tuple(data)
print(data)
print(mytuple)
Then , try sth like:
for adding in mytuple:
print("{0:4d} {1:4d}".format(adding)) # i am not adding here,i just print
I have two problems: 1) I don't know how to add the elements. 2) When i add the second part of the code(the adding) ,when i press enter instead of causing the break of the program it continues to ask me "Enter two integers"
Thank you!