(Python 2.7) In my previous question, I was trying to iterate through the keys of the dictionary "rooms" and show only two keys per line, how can I go about showing an odd number of rooms at a time? More specifically, two per line until only one is left and only that one will go on a line on its own.
Current Code:
rooms = {
"101": "Classroom",
"102": "Bathroom",
"103": "Room",
"104": "Room",
"105": "Room",
"106": "Room"}
keys = iter(sorted(rooms.keys()))
for key in keys:
print key + " " + next(keys)
Current Output:
101 102
103 104
105 106
Goal Output:
101 102
103 104
105 106
107