Python Forum
Can not get quiz game to work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can not get quiz game to work
#3
I am no admin but you should post your code in Python tags.

Your code if-clause will always evaluate to True therefore you get always if branch.

Why it evaluates to True? You have or condition. If either part of or is True then if-clause is True. String evaluates to True if it is not empty. String is False then it is empty. As 'ankara' is not empty string it always truthy.

>>> if 'ankara':
...     print('this is true')
...
this is true


You can remedy it by writing correctly:

if turkeycapital == "Ankara" or turkeycapital == "ankara":
But more commone way is to convert either lower or uppercase:

if turkeycapital.lower() == 'ankara':
This way you'll cover all caps and typos as well.

And of course, else-clause misses print statement.

And if there is more than one question you should use function.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Can not get quiz game to work - by funkymonkey123 - Feb-03-2019, 11:24 AM
RE: Can not get quiz game to work - by buran - Feb-03-2019, 12:03 PM
RE: Can not get quiz game to work - by perfringo - Feb-03-2019, 12:16 PM
RE: Can not get quiz game to work - by chesschaser - Jul-02-2020, 03:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  QUIZ GUI Form_When admin panel is open, main quiz form is getting freeze Uday 4 745 Aug-25-2023, 08:24 PM
Last Post: deanhystad
  Guessing Game does not work the_entrepreneur 3 2,795 Apr-20-2019, 06:19 AM
Last Post: SheeppOSU

Forum Jump:

User Panel Messages

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