I'm relatively new to Python and just got introduced to functions. I'm working on an example and don't quite understand how to write the needed function.
The input to the function is a list of strings in the following format:
lines = ['1: 362.5815 162.5823\n',
'2: 154.1328 354.1330\n',
'3: 168.9325 368.9331\n',.. ]
I have to create a function that converts each item in the list into a tuple and stores the output in a new list.
To convert a single item of the list into a tuple, I am using the following code:
f1 = lines[0].split(" ")
f1tuple1 = tuple(f1)
f1tuple2 = (f1tuple[0], [float(f1tuple[1]), float(f1tuple[2])])
How do I perform the same action for all of the items in the list? I would really appreciate help in this matter.
forloops.