0
numCat = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
print("Hello user, I am Inverted Cheese.\n")
username = input("What is your name?\n").capitalize()
print("Hello, " + username + "!")

while True:
    if input() == "hello":
        print("Hello, " + username + "!")
    elif input() == "cat":
        num = randrange(0,10)
        print(num)
        if num == 0:
            numcat[num] += 1
            print("You now have " + numcat[num] + "brown cats")
        elif num == 1:
            numcat[num] += 1
            print("You now have " + numcat[num] + "grey cats")
        elif num == 2:
            numcat[num] += 1
            print("You now have " + numcat[num] + "white cats")
        elif num == 3:
            numcat[num] += 1
            print("You now have " + numcat[num] + "black cats")
        elif num == 4:
            numcat[num] += 1
            print("You now have " + numcat[num] + "orange cats")
        elif num == 5:
            numcat[num] += 1
            print("You now have " + numcat[num] + "furless cats")
        elif num == 6:
            numcat[num] += 1
            print("You now have " + numcat[num] + "hairy cats")
        elif num == 7:
            numcat[num] += 1
            print("You now have " + numcat[num] + "small cats")
        elif num == 8:
            numcat[num] += 1
            print("You now have " + numcat[num] + "fat cats")
        elif num == 9:
            numcat[num] += 1
            print("You now have " + numcat[num] + "chubby cats")
        elif num == 10:
            numcat[num] += 1
            print("You now have " + numcat[num] + "magic cats")
        print(num)
    elif input() == "inventory1":
        print("hi)")
        print("Inventory Part I:\n\nCommon Cats:\nBrown: " + numCat[0] + "\nGrey " + numCat[1] + "\nWhite: " + numCat[2] + "\nBlack: " + numcat[3] + "\nOrange: " + numCat[4] + "\n\nRare Cats:\nFurless: " + numCat[5])
        print("hi)")
    elif input() == "inventory2":
        print("hi)")
        print("Inventory Part II:\n\nRare Cats:\Hairy: " + numCat[6] + "\nSmall: " + numCat[7] + "\n\nEpic Cats:\nFat: " + numCat[8] + "\nChubby: " + numCat[9] + "\n\nLegendary:\nMagic: " + numCat[10])
        print("hi)")

input()

The only command that works is the "hello" command, but the "cat" and both inventory commands don't work. When I try and use them, I get no output. Could someone please explain why?

It also won't print anything. I've added print commands in the inventory code, but they won't print. Is there something I'm doing wrong with my list?

I really want to get this program running, but I'm completely lost here.

Alex Ruan
  • 13
  • 4
  • 2
    Read [How to debug small programs](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/). Debugging skills are vital for developers. So that "someone" should be *you*. Consider storing *every* `input()` in some variable and printing it (for debugging purposes). And StackOverflow is not a *debug-my-code* site. – Basile Starynkevitch Sep 11 '18 at 04:30
  • Also, take time to read the [documentation of Python](https://docs.python.org/3/), in particular read the documentation of *every function* that you are using – Basile Starynkevitch Sep 11 '18 at 04:33

2 Answers2

2

You would be reading new input in every elif evaluation. Store the input once, so you can repeatedly compare it:

i = input()
if i == "hello":
    print("Hello, " + username + "!")
elif i == "cat":
    # ...
elif i == ...:
    # ...
user2390182
  • 72,016
  • 6
  • 67
  • 89
1

Every call to input() would require another input from the user. You should call input() once and store the returning value in a variable for comparison:

while True:
    command = input()
    if command == "hello":
        print("Hello, " + username + "!")
    elif command == "cat":
        num = randrange(0,10)
        print(num)
        ...
blhsing
  • 91,368
  • 6
  • 71
  • 106