Recording the history of Nellore

Uncategorized

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

Discover more from Nellorean

Subscribe now to keep reading and get access to the full archive.

Continue reading