We use Python 3.6

go back Level: Beginner (img: BG / score: 2) level Bite 64. Fix a truncating zip function

145 out of 147 users completed this Bite ...
Will you be Pythonista #146 to crack this Bite?
Average Bite difficulty 1-10 rating: 3.0
» You can do it! 😌

Bert is in charge of organizing an event and got the attendees names, locations and confirmations in 3 lists. Assuming he got all data and being Pythonic he used zip to stitch them together (see template code) but then he sees the output:

('Tim', 'DE', False)
('Bob', 'ES', True)
('Julian', 'AUS', True)
('Carmen', 'NL', False)
('Sofia', 'BR', True)

What?! Mike, Kim, and Andre are missing! You heard somebody mention itertools the other day for its power to work with iterators. Maybe it has a convenient way to solve this problem? Check out the module and patch the get_attendees function for Bert so it returns all names again. For missing data use dashes (-). After the fix Bert should see this output:

('Tim', 'DE', False)
('Bob', 'ES', True)
('Julian', 'AUS', True)
('Carmen', 'NL', False)
('Sofia', 'BR', True)
('Mike', 'US', '-')
('Kim', '-', '-')
('Andre', '-', '-')

Good luck, Bert will be grateful if you fix this bug for him! By the way, this won't be the last itertools Bite, it is a power tool you want to become familiar with!

Github login button