I've approached this question that I'm struggling to solve. It's asking me to convert the code from "for-loops" to "while-loops":.
def print_names2(people):
for person in people:
to_print = ""
for name in person:
to_print += name + " "
print(to_print)
I've only managed to do the first half:
def print_names2(people):
i = 0
while i < len(people[i]):
print(i)
i += 1
When I test it with:
print_names2([['John', 'Smith'], ['Mary', 'Keyes'], ['Jane', 'Doe']])
Returns:
0
1
Could someone clarify to me how to do it, as I'm pretty sure my approach to the answer is a bit far away.