I want to get multiple inputs as tuples in a list.
Example: [(1,2),(1,3),(1,4),(2,5)]
I wrote this code, it works not bad. But I'm just wondering if there is another way to do this or can we make this code clear?
def make_tuple(k):
tup_list = []
for i in range(0, len(k)-1, 2):
tup_list.append((k[i],k[i+1]))
return tup_list
list1 = list(map(int, input("Enter multiple values: ").split()))
make_tuple(list1)
In this way, user should enter the input like;
1 2 1 3 1 4 2 5 for getting [(1,2),(1,3),(1,4),(2,5)].
The actual thing I want is enter the input like;
1,2 1,3 1,4 2,5