Python Forum
what's wrong? i know this is simple
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what's wrong? i know this is simple
#12
Your original code works fine for me without any delay (Windows, Python 3.10, cmd shell). It would appear that the clear command does not execute immediately on your system. This is not a Python thing. This could be an OS thing or a shell thing or an IDE thing. What happens when you run it outside of spyder?

This is a version of your program that does not contain any hard-coded passwords. Enter the word you want to remember and do your testing. Exit testing and you can work on a different password.
import os
from time import sleep


def password_test():
    password = input("Enter a password: ")
    while True:
        os.system("cls")
        sleep(0.1)
        if input("What is the password: ") == password:
            print("Match")
        else:
            print("No match")

        if input("Run again (y/n)? ").lower() != "y":
            break


while True:
    password_test()
    if input("Learn a different password (y/n)? ").lower() != "y":
        break
Reply


Messages In This Thread
what's wrong? i know this is simple - by davidorlow - Mar-15-2023, 12:47 AM
RE: what's wrong? i know this is simple - by deanhystad - Mar-15-2023, 05:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I have a code which is very simple but still I cannot detect what's wrong with it max22 1 516 Nov-07-2023, 04:32 PM
Last Post: snippsat
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,646 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  python gives wrong string length and wrong character thienson30 2 3,052 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  simple dragon realm gone wrong Darbandiman123 7 5,606 Mar-01-2017, 05:25 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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