Hi I'm a python beginner!
I'm trying to make a list of 3 numbers per line but I get an error. =(
Here's my code:
list2 = [23, 764, 12, 54, 83, 2, 543, 890, 1235, 453, 98]
k = 0
while list2[k] != -1:
first = str(list2[k])
k = k + 1
second = str(list2[k])
k = k + 1
third = str(list2[k])
k = k + 1
print first.ljust(3), second.ljust(3), third.ljust(3)
last = list2[-1]
Python Shell: the "-" represents spaces and for some reason the spaces aren't showing when I paste it here.
23-------764------12
54-------83--------2
543------890------1235Traceback (most recent call last):
File "C:\Users\Me\Documents\blahh.py", line 9, in <module>
third = str(list2[k])
IndexError: list index out of rangeprint last.ljust(3)