Python Forum
Python Hangman Replacing "_" with letters.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Hangman Replacing "_" with letters.
#6
(Jun-24-2018, 05:05 PM)gontajones Wrote:
Quote:while '_' in guess_word:

This will keep asking for new guess(letter) until there is no more '_' in the guess_word (the word is formed).

OK, sorry, my mistake - I missed the part that you change the original word (I was talking about checkLetter function) - but calling word.index( c ) is unneeded if you use enumerate - and calling it twice is wasteful. You are building a mechanism that Python provides you under the hood.
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Messages In This Thread
RE: Python Hangman Replacing "_" with letters. - by volcano63 - Jun-25-2018, 10:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  eliminating letters when typed in python window deebo 0 1,762 Jan-05-2021, 09:26 AM
Last Post: deebo
  Replacing a words' letters in a string cananb 2 3,518 Dec-01-2020, 06:33 PM
Last Post: perfringo
  Python Hangman Game - Multiple Letters Problem t0rn 4 4,789 Jun-05-2020, 11:27 AM
Last Post: t0rn
  Hangman metro17 4 3,077 Sep-18-2019, 10:59 AM
Last Post: perfringo
  Trouble coding hangman Tay 1 2,388 Mar-28-2019, 01:57 AM
Last Post: ichabod801
  Hangman code problem KrakowKid 1 2,433 Feb-25-2019, 06:29 PM
Last Post: ichabod801
  Python hangman help A1395 11 7,320 Feb-13-2019, 04:24 PM
Last Post: ichabod801
  Replacing all letters in a string apart from the first letter in each word Carbonix 9 5,018 Jan-17-2019, 09:29 AM
Last Post: buran
  Hangman 2skywalkers 3 78,565 Oct-19-2018, 01:49 PM
Last Post: ichabod801
  Replacing letters on a string via location Owenix 2 2,502 Sep-16-2018, 10:59 AM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

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