Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

I do bot know what did I do incorrect

+4 votes
asked Sep 29, 2021 by Ibo Kerimli (160 points)

score = 0
print("Hello user")
print("do you want to answer my riddles")
print("of course yes)")
while input("What can be touched but can't be seen?") !=heart:
    print ("wrong")
print("well done") and score = score + 1
print(score)

3 Answers

+1 vote
answered Sep 30, 2021 by Admin (4,940 points)
Thanks for sharing snippet of code in question.
It would be more helpful if you share details about what you wanted to achieve with this code and where exactly you get stuck. It would be helpful for the fellow users to understand problem and help you.
+1 vote
answered Sep 30, 2021 by Peter Minarik (55,760 points)

Legend

  • red: content removed
  • green: content added

Your code fixed:

score = 0
print("Hello user")
print("do you want to answer my riddles")
print("of course yes)")
while input("What can be touched but can't be seen?") != "heart":
    print("wrong")
print("well done") and[ENTER]
score = score + 1
print(score)
+1 vote
answered Dec 6, 2021 by Christopher (170 points)

There are a couple of things wrong. First, when checking if input is heart, you want heart in quotes since it is a string.

It goes from this:

while input("What can be touched but can't be seen?") != heart:

to this:

while input("What can be touched but can't be seen?") != "heart":

It is a small change, but it turns heart from a variable to a string.

Secondly, you can't do "print and". You would use and like this:

if x == 0 and y == 1:

The like would go into two separate lines, like this:

print("well done")
score = score + 1

The fixed code looks like this:

score = 0
print("Hello user")
print("do you want to answer my riddles")
print("of course yes")
while input("What can be touched but can't be seen?\n") != "heart":
    print ("wrong")
print("well done")
score = score + 1
print(score)

Also, you want \n at the end of the input so the next print goes on a different line ("\n" is the way to insert a newline).

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...