repl.it
@big_deelan/

List help

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def main():
  #Set up an empty list.
  mylist = []
  
  #numlist counts the first, second, third etc number to input.
  numlist = ["first", "second", "third", "fourth", "fifth"]
  
  #Collect user input to append to the list (using numlist to count words entered).
  for x in range (5):
    word = input("Please input your " + numlist[x] + " word: ")
    mylist.append(word) 
  choice = input("\nWould you like to change an index? y/n ")
  if choice == "y" or "Y":
    change(mylist)
  else:
    printit(mylist) 

  printit(mylist)
  
#Print list in line without quotes or brackets
def printit(mylist):
  print("\nList: \n")
  for x in range(len(mylist)):
    mylist.sort()
    print(mylist[x], end = "\t")
  print("")

#Changing a value
def change(mylist):
  tochange = int(input("\nWhat index would you like to change? "))
  newitem = input("What would you like to change it to? ")
  mylist[tochange] = newitem
  
if __name__ == "__main__":
  main()
Fetching token
?