Python Exercise9

Write a program to stop the search as soon as we find 50 in the list

numbers = [100, 25, 125, 50, 150, 75, 175]

for x in numbers:

print( x )

if x == 50:

print( “Found It!” )

break

Write a program to skip all triple digit numbers

numbers = [100, 25, 125, 50, 150, 75, 175]

for x in numbers:

if x >= 100:

continue

print( x )

<

Write a program to unpack the values to variables

colors=”red,blue,green,yellow,pink”
#print(colors.split(‘,’))               # list of colors
r,b,g,y,p=colors.split(‘,’)            # unpacked in to variables
print(r,b,g,y,p)

Write a program to join each value with **using  join

colors=[“red”,”blue”,”green”,”yellow”,”pink”]
print(“**”.join(colors))

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