Bitwise 4/14 [SPOILERS] Printing with list and function


#1

Here is a roundabout but fun way to solve:

You can generate a list, then a function that takes the list and prints on each line, then call the function.

mylist = [bin(x) for x in range(2,6)]

def list_item(list):
for items in list:
print items

list_item(mylist)

Pardon the formatting; the function required proper indentation- one additional indent level for each line.


#2

Updated formatting for those interested in readability:

mylist = [bin(x) for x in range(2,6)]

def list_item(list):
  for items in list:
    print items

list_item(mylist)

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.