Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hi how do i solve this ?
#3
Hm, the code works.
Maybe you've missed an indentation. We can't see it here, because white space are stripped away, if you don't put you code into code tags.

This works, but you can simplify this very much.
while True:
    print("Where is Moscow located at?")
    answer1 = input("a) Russia\nb) China\nc) Japan\nd) Mongolia\nAnswer: ")
    if answer1 == "a" or answer1 == "Russia":
        print("Right Answer!")
        break
    if answer1 == "b" or answer1 == "China":
        print("Wrong Answer!")
    if answer1 == "c" or answer1 == "Japan":
        print("Wrong Answer!")
    if answer1 == "d" or answer1 == "Mongolia":
        print("Wrong Answer!")
    else:
        print("Error!")
The simpler version:
while True:
    print("Where is Moscow located at?")
    answer1 = input("a) Russia\nb) China\nc) Japan\nd) Mongolia\nAnswer: ")
    if answer1 == "a" or answer1 == "Russia":
        print("Right Answer!")
        break
You can do it once right and make a function for it:
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
Hi how do i solve this ? - by Houston222 - Feb-05-2020, 03:51 PM
RE: Hi how do i solve this ? - by t4keheart - Feb-05-2020, 04:36 PM
RE: Hi how do i solve this ? - by DeaD_EyE - Feb-05-2020, 04:42 PM
RE: Hi how do i solve this ? - by buran - Feb-05-2020, 04:51 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020