Python Forum
If 2nd input in the game is correct, replace with 1st input and loop the game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If 2nd input in the game is correct, replace with 1st input and loop the game
#2
There is no condition for the you lost line. It will always print.
you will need something like
if second_data == first_data:
    # continue with whatever
else:
    print('you lost')
On a side note that should probably be in the while loop


Here is an example for you to play around with

while True:
    print('ctrl c to quit')
    first = input('country name: ')
    second = input('another name: ')

    last_letter = first[-1]
    first_letter = second[:1]

    if last_letter == first_letter:
        print('correct')
    else:
        print('wrong answer')
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
RE: If 2nd input in the game is correct, replace with 1st input and loop the game - by menator01 - Jul-14-2022, 07:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Game "Fluppy bird" nastia_nadashkevich 1 310 Apr-19-2024, 08:45 PM
Last Post: deanhystad
  [PyGame] Waiting screen until user input - PiBooth world90 2 1,032 Apr-19-2024, 03:34 AM
Last Post: attractalderman
  [PyGame] adding mouse control to game flash77 2 319 Apr-08-2024, 06:52 PM
Last Post: flash77
  Isometric game pygame Tiled howardberger 1 682 Jan-31-2024, 10:01 PM
Last Post: deanhystad
  I want to add a bullet function to my game. how would i go about it? Iyjja 5 1,033 Jan-09-2024, 05:42 PM
Last Post: Iyjja
  GPS Points to map for game/simulator AvgPlum 2 1,995 Jun-22-2023, 06:38 PM
Last Post: marynetherton
  [PyGame] When I hit the space bar from the home screen, it sends me to the game over screen JesusisKing 1 1,054 Apr-30-2023, 10:11 PM
Last Post: deanhystad
  Laggy Game Movement game_slayer_99 12 4,548 Oct-05-2022, 11:34 AM
Last Post: metulburr
  can't get collision detection to work in platform game chairmanme0wme0w 10 3,923 Aug-19-2022, 03:51 PM
Last Post: deanhystad
  [PyGame] AI Techniques applied to a Game insignia47 1 1,548 Jun-17-2022, 05:25 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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