Python

4 Python LIST – Looping through a slice

Python LIST

Looping Through a SLICE

print("Looping through SLICE code")
players = ['Vijay', 'Mohan', 'Vasu', 'Sai', 'Chandika','Shreya']
print("Here are the first three players on my team:")
for player in players[:3]:
print(player.title())

Results

Looping through SLICE code
Here are the first three players on my team:
Vijay
Mohan
Vasu

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s