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
#11
Always happy to help Smile
Reply
#12
I would keep the word chain to report at the end of the game, or to compute a score.
words = [input('enter a country name: ')]
while True:
    word = input('enter a country name starts with the last letter of previous country name: ')
    if word and word[0].lower() == words[-1][-1].lower():
        words.append(word)
    else:
        break
print(f"So sorry, The first letter of {word} does not match the last letter of {words[-1]}.")
print(f"Your word chain {words}")
tylerdurdane likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to put my game loop into a function? temlotresid6 8 2,348 May-07-2025, 12:54 PM
Last Post: ekaintan1590
  [PyGame] Best way to pass data to the few game states with the same superclass? Milosz 6 4,741 May-05-2025, 07:48 AM
Last Post: DumbleJum
  My first python game : Tic-Tac-Toe ForsakenDusk 7 44,286 Feb-25-2025, 02:06 PM
Last Post: from1991
  [PyGame] Problem when moving game window michael1789 17 13,711 Feb-11-2025, 09:54 AM
Last Post: alexjordan
Lightbulb (Series) Advanced Game Design Articles for Setting Up an Infinite Metagame Reactorcore 0 626 Dec-15-2024, 08:49 PM
Last Post: Reactorcore
  [PyGame] Waiting screen until user input - PiBooth world90 4 3,625 Oct-08-2024, 07:52 AM
Last Post: DumbleJum
  [PyGame] Input is not defined Forno_Gamer 3 2,140 Sep-08-2024, 09:11 AM
Last Post: deanhystad
  [PyGame] When I hit the space bar from the home screen, it sends me to the game over screen JesusisKing 2 2,797 Jul-31-2024, 08:10 AM
Last Post: Mollycoddle
  [PyGame] little space invaders / breakout game flash77 0 1,372 Jul-24-2024, 08:56 PM
Last Post: flash77
  [PyGame] Game restart problem senka_25 4 3,096 Jun-24-2024, 09:49 PM
Last Post: AdamHensley

Forum Jump:

User Panel Messages

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