Python Lists
Introduction
A list stores a series of items in a particular order. you access items using an index, or within a loop.
#Make a list bikes =['trek', 'redline', 'giant'] #Get the first item in a lists first_bike =bikes[0] #Get the last item in a list last_bike =bikes[-1] #looping through a list for bike in bikes: print(bike) #Adding item to list bikes = [] bikes.append('trek') bikes.append('redline') bikes.append('giant') print(bikes) #Making numerical lists square = [] for x in range (1,11): square.append(x**2) print(square)
No comments:
Post a Comment