Answer to Question #349609 in Python for Omar

Question #349609

Make a list contain any 4 names and also using for loop to print this list and please print the last string in the list



1
Expert's answer
2022-06-09T18:21:57-0400
 # variant 1
some_name = ['Nick', 'Andrew', 'Daniel', 'Mark']
del some_name[-1]
for i in some_name:
    print(i)
# variant 2
some_name = ['Nick', 'Andrew', 'Daniel', 'Mark']
a = some_name[-1]
some_name2 = []
for i in some_name:
    if i != a:
        some_name2.append(i)

for a in some_name2:
    print (a)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS