Python Forum
Ask again if wrong guess with While.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ask again if wrong guess with While.
#4
while name will always be True so you may as well just use while True.
Indentation should be 4 spaces.
You can use f strings.
if name is a constant use capital letters otherwise lowercase is ok.
NAME = "Ed"

while True:
    guess = input("what is the name")
    if guess != NAME:
        print(f"{guess} is wrong")
    else:
        print(f"{guess} is the right name")
        break
EduPy likes this post
Reply


Messages In This Thread
Ask again if wrong guess with While. - by EduPy - Oct-21-2021, 04:43 PM
RE: Ask again if wrong guess with While. - by Yoriz - Oct-21-2021, 04:49 PM
RE: Ask again if wrong guess with While. - by EduPy - Oct-21-2021, 07:10 PM
RE: Ask again if wrong guess with While. - by Yoriz - Oct-21-2021, 07:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Guess the word game help jackthechampion 3 3,077 Sep-06-2023, 06:51 AM
Last Post: Pedroski55
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,646 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  I guess it's about print tsavoSG 2 2,151 Feb-08-2021, 08:34 PM
Last Post: steve_shambles
  python gives wrong string length and wrong character thienson30 2 3,051 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  can't figure out problem with number guess Galoxys 4 3,400 Oct-29-2018, 01:45 PM
Last Post: snippsat
  Guess a number Ameen 5 13,196 Apr-03-2018, 01:20 PM
Last Post: snippsat
  Guess Random Number Why i m not able to enter input Nithya Thiyagarajan 6 8,269 Jan-07-2018, 04:26 AM
Last Post: squenson
  "Guess the Number" game CTT 14 13,502 Jul-26-2017, 11:41 AM
Last Post: sylas

Forum Jump:

User Panel Messages

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