google.com, pub-8786015629279405, DIRECT, f08c47fec0942fa0 Write instructions to perform each of the steps below (a) Create a string containing at least five words and store it in a variable. (b) Print out the string. (c) Convert the string to a list of words using the string split method. (d) Sort the list into reverse alphabetical order using some of the list methods. (e) Print out the sorted, reversed list of words.

Write instructions to perform each of the steps below (a) Create a string containing at least five words and store it in a variable. (b) Print out the string. (c) Convert the string to a list of words using the string split method. (d) Sort the list into reverse alphabetical order using some of the list methods. (e) Print out the sorted, reversed list of words.

0

 



Write instructions to perform each of the steps below 

(a) Create a string containing at least five words and store it in a variable. 

(b) Print out the string. 

(c) Convert the string to a list of words using the string split method. 

(d) Sort the list into reverse alphabetical order using some of the list methods.

 (e) Print out the sorted, reversed list of words.


# Program

 

# (a) Create a string containing at least five words and store it in a variable.

 

str1 = "I proud to be an Indian"

 

# (b) Print out the string.

 

print(str1)

 

# (c) Convert the string to a list of words using the string split method.

 

li = list(str1.split(" "))

print(li)

 

# (d) Sort the list into reverse alphabetical order using some of the list methods.

 

li1 = sorted(li)

print(li1)

def Reverse(list1) :

    return [element for element in reversed(list1)]

# (e) Print out the sorted, reversed list of words.

print(Reverse (li1))

 

 

Output:

 

I proud to be an Indian

['I', 'proud', 'to', 'be', 'an', 'Indian']

['I', 'Indian', 'an', 'be', 'proud', 'to']

['to', 'proud', 'be', 'an', 'Indian', 'I']




Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Thank you for your interest 😊

We will back shortly after reviewing...

Thank you for your interest 😊

We will back shortly after reviewing...

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top