def print_names2(people): for person in people: to_print = "" for name in person: to_print += name + " " print(to_print) def print_names2_while_version(people): i = 0 while i < len(people): to_print = "" person = people[i] j = 0 while j < len(person): name = person[j] to_print += name + " " j += 1 j = 0 i += 1 print(to_print) people = [('Michael', 'Jordan'), ('Jim', 'Raynor'), ('Jimi', 'Hendrix')] print("For Loop Function: ") print_names2(people) print('\n') print("While Loop Function: ") print_names2_while_version(people)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question