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
#1
Ok, I'm a struggling programmer. Dabbled in it for years and never get any better than a basic hello world programmer. LOL.

I'm trying to write a script that tests me on a password. I'm terrible at remembering passwords and I shouldn't be writing down my admin passwords. They should be in my head. So, I was searching for a program that would test me and found there are none. So, I figured, maybe I'll see if I can figure it out in Python. The script worked until I put the clear statement in it. I'm trying to clear the screen so I can't look at it when it runs again... I need to memorize it. But, for whatever reason I'm not seeing, when I put the clear there, it asks the question real quick "what's my password" then clears the screen. I'd think since it's below the input line, it would display the question and wait for me to input something before it moves on to the next line to clear it. But it's not even making it to the run again part. The clear screen is wiping out the prompt to ask for the password.

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

import os

repeat = "y"

while repeat=="y":

    mypassword = "test123"
    guesspassword = input("What is the password: ")
    if guesspassword==mypassword:
        print("match")
        input("Press Enter")

    else:
        print("no match")
        print("Password is ", mypassword)
        input("Press Enter")

    repeat = input("Run again?")
    os.system('cls')
If you all told me I just found a bug in python, that would make my day. I know I'm doing something elementary stupidly wrong.
Reply


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

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