Python List - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Python List - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Friday, November 30, 2018

Python List

Python Lists


python list


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)


Screenshot

python list

 

No comments:

Post a Comment

Post Top Ad