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
  Simple Game - Choice Based theor 4 3,182 May-22-2024, 01:17 PM
Last Post: alanbriggs
  My first python game : Tic-Tac-Toe ForsakenDusk 5 336 May-21-2024, 03:24 AM
Last Post: deanhystad
  [PyGame] adding mouse control to game flash77 7 649 May-21-2024, 01:05 AM
Last Post: XavierPlatinum
  get a game to run in full screen mode agencyclearly 1 475 May-12-2024, 11:23 AM
Last Post: menator01
  Game "Fluppy bird" nastia_nadashkevich 1 453 Apr-19-2024, 08:45 PM
Last Post: deanhystad
  [PyGame] Waiting screen until user input - PiBooth world90 2 1,203 Apr-19-2024, 03:34 AM
Last Post: attractalderman
  Isometric game pygame Tiled howardberger 1 856 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,224 Jan-09-2024, 05:42 PM
Last Post: Iyjja
  GPS Points to map for game/simulator AvgPlum 1 2,078 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,138 Apr-30-2023, 10:11 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