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
#11
Your original code works.
You need to run it from the Windows terminal - that is where the cls command works
Run cmd, navigate to the folder where you have the app, and then enter a command line like:
Quote:python -m test.py
Reply
#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


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 491 Nov-07-2023, 04:32 PM
Last Post: snippsat
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,575 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  python gives wrong string length and wrong character thienson30 2 3,025 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  simple dragon realm gone wrong Darbandiman123 7 5,585 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