Scramble Words Game

In this program, we will learn how we can use indexing and manipulate the list according to our need.

# at first store a string variable
my_string = 'HARMONY'
# let's use list comprehension for converting the string to a list: chr is each character
my_list = [chr for chr in my_string]
# let's print the list
print(my_list)
# check the list elements with indexing
for elem in enumerate(my_list):
    print(elem)
# scramble the list elements with indexing: 
# here i = index
for i in range(3):
    # perform swaps: scramble
    my_list[i],my_list[i+1] = my_list[i+1],my_list[i]
# list after scambing
print(my_list)
# again check the list elements with indexing
for elem in enumerate(my_list):
    print(elem)