Python Forum
Python Hangman Game - Multiple Letters Problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Hangman Game - Multiple Letters Problem
#2
The find function returns the index of the first instance found. That's why it stops working after the first one is found. If it doesn't find an instance then it returns -1. What you need to do is keep running find in a loop until it returns -1.
Something like:
while full_word.find(guess):
    selected_word = selected_word[:checker] + guess + selected_word[checker+1:]
Reply


Messages In This Thread
RE: Python Hangman Game - Multiple Letters Problem - by Clunk_Head - Jun-04-2020, 02:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python convert multiple files to multiple lists MCL169 6 1,570 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  Stacking Problem in a game. HelloTobi22 2 1,012 Aug-05-2022, 09:48 AM
Last Post: HelloTobi22
  Problem with my pong game code Than999 8 3,876 May-15-2022, 06:40 AM
Last Post: deanhystad
  Problem restricting user input in my rock paper scissors game ashergreen 6 4,641 Mar-25-2021, 03:54 AM
Last Post: deanhystad
  multiple condition if statement problem FelixReiter 3 2,614 Jan-11-2021, 08:07 AM
Last Post: FelixReiter
  eliminating letters when typed in python window deebo 0 1,750 Jan-05-2021, 09:26 AM
Last Post: deebo
  Guessing game problem IcodeUser8 7 3,674 Jul-19-2020, 07:37 PM
Last Post: IcodeUser8
  game of the goose - dice problem koop 4 3,508 Apr-11-2020, 02:48 PM
Last Post: ibreeden
  Problem with accepting multiple string inputs Ryan_Todd 5 2,966 Jan-22-2020, 06:12 PM
Last Post: buran
  Plot multiple csv into one graph problem with visualize linkxxx86 1 5,737 Oct-14-2019, 05:54 PM
Last Post: linkxxx86

Forum Jump:

User Panel Messages

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