question archive Python code only please, im having trouble with doing this

Python code only please, im having trouble with doing this

Subject:Computer SciencePrice: Bought3

Python code only please, im having trouble with doing this.

Find the string that comes first alphabetically from a list of strings. The strings may contain alphabetic and non-alphabetic characters, but you can assume that all alphabetic characters in each string will be in lowercase, i.e. no string contains any uppercase characters. Do NOT use the sort() method for lists, or the built-in min() or max() functions.

A) Define a list L1 consisting of at least 10 strings (e.g. L1 = ['green', 'pink', '123', 'abc12', 'tree', 'house', 'cat', 'dog' 'red', 'green']) and print L1 with suitable message.

B) Initialize a str variable first to empty string. This variable represents the string that comes first alphabetically from the list elements checked so far.

C) In a loop, do the following:

I) Check each element to see if it is an alphabetic string. If a string contains only alphabetic characters it is compared with the current value of first. Update the value of first to the current element, is appropriate.

II) If a string contains any non-alphabetic characters it is ignored and a suitable message is printed.

D) After exiting from the loop:

I) If no string in L1 contained only alphabetic characters, print a message indicating that.

II) Otherwise, print a message with the alphabetic string that comes first in alphabetic order.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE