Changes

Jump to: navigation, search

OPS435 Python Lab 4

10 bytes added, 19:20, 21 June 2017
PART 2 - String Formatting
:#Let's demonstrate by issuing the following:<source>
list1 = [1,2,3,4,5] # This is a list of numbers
print('{0[0]} {0[1]} {0[2]} {0[3]} {0[4]}'.format(list1)) # Access the values of the list via using indexes {position[index]}
print('{0} {1} {2} {3} {4}'.format(*list1)) # Expand the list into multiple positional arguments
print('{} {} {} {} {}'.format(*list1)) # Expand the list into multiple positional arguments
13,420
edits

Navigation menu