# Check my code?

That is my instructions-
pet = input(“What pet do you have? (rock to stop)”)
c = 0
while (pet != “rock”):
pet = input(“What pet do you have? (rock to stop)”)
c = c + 1
print(“You have a " + pet + " with a total of " + str(c) + " pet (s)”)

There’s my code. It’s not working the way it’s supposed to. You can copy & paste the code to test it if you’d like.

Do you have a link to the CC lesson you’re referring to?
Is this for a coding test or homework assignment?

This isn’t part of CC, it’s a different site- but since this is python I figured I could still get some help from here.

Check if its indented correctly;
the things inside of the loop that repeat on each iteration must be indented.

Assuming rocks count as pets:

``````pet = input("What pet do you have? (rock to stop)")
c = 1   # should be 1, not 0, because already entered a pet
# no print for c = 1  (so first pet is skipped)

while (pet != "rock"):
pet = input("What pet do you have? (rock to stop)")
c = c + 1
print("You have a " + pet + " with a total of " + str(c) + " pet(s)")
print("total number of pets: " + str(c))
``````

Running the code sample shown by @janbazant1107978602 (same logic as your code) produces the following output:

What pet do you have? (rock to stop)dog

``````# there's no output after the first pet is entered
``````

What pet do you have? (rock to stop)cat
You have a cat with a total of 2 pet (s)
What pet do you have? (rock to stop)potato
You have a potato with a total of 3 pet (s)
What pet do you have? (rock to stop)rock
You have a rock with a total of 4 pet (s)
total number of pets: 4

The issue may be that the first pet is ignored in the output.