Advertisement
Guest User

My revised program

a guest
Dec 13th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. wordList = []
  2.  
  3. for items in range(5):
  4.    words = input("Enter a word: " )
  5.    wordList.append(words)
  6.  
  7. numList = 1
  8. for x in wordList:
  9.    print(numList,x)
  10.    numList += 1
  11.    
  12. print("Do you want to swap any 2 items? ")
  13. wantSwap = input("y = yes, anything else = no: ")
  14.  
  15. while wantSwap.upper() == "Y":
  16.       numList -= 5
  17.       w1 = int(input("Enter the first number to swap: ")) -1
  18.       w2 = int(input("Enter the second number to swap: ")) -1
  19.       wordList[w1], wordList[w2] = wordList[w2], wordList[w1]
  20.       print("Here is the revised list:")
  21.       for x in wordList:
  22.          print(numList,x)
  23.          numList += 1
  24.       print()
  25.       print("Do you want to do it again? ")
  26.       wantSwap = input("y = yes, anything else = no: ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement