So I'm starting to learn python as it's an awesome language from what I've already done in it.
I came across an exercise to learn lists and it was basically as follows
Create a list of first names and a list of second names and use a for loop to print out all the full names.
So heres my lists
names = ["Jake", "Ben", "Rob"] surnames = ["Cowton", "Fielding", "Spenceley Jones"]
and heres what I tried first
for i in names: for j in surnames: print(i + " " + j)
Which obviously is wrong.
I then worked out I should do this
for i in range(0, len(names)): print(names[i] + " " + surnames[i])
Which gave me what I wanted.
However, I'm now thinking, is there a way of iterating through two lists in one for loop to shorted this solution. For example something like this
for x, y in names, surnames: print(x + " " + y)
I know this doesn't compile, but does anybody know if theres a way of doing this?