Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Password Generator
#1
Photo 
So, I've been trying to write this code that would tell me to stop once I entered the wrong password three times in a row and I don't know how to do it. Disclaimer, I'm very new to Python 3. I wrote the python code below for password input but it doesn't prompt me to stop after three attempts. What should I add to this code? or what should I delete so I can achieve what I wanted it to do. Just need some boost and help so I can clear my mind. (^^o) Can't seem to sleep at night when you don't get what you want to happen with your code. A bit of help is appreciated! Thanks!

password = str(input("Please enter password to continue: ")) if password == "fusion": print("Welcome! the password is correct, you may enter.") exit() while password != "fusion":	print("what is the Password?")	password = input() while password == "fusion":	print("Welcome! the password is correct, you may enter.")	exit()
Thank you,
Josh
Reply
#2
Hi,
I'm a newbie too!. I've done something with my knowledge, please check whether it suits for you.


password=str(input("Enter the password:")) if password=='fusion': print ("Welcome!the password is correct, you may enter.") exit() while password!='fusion': i=0 while i<3: password=str(input("You have entered invalid password, please enter teh password again:")) if password=='fusion': print ("Welcome!the password is correct, you may enter.") exit() i+=1 print ("You have reached the maximum limit") break
Reply
#3
I know how to do this is Python 2. I'm pretty much a beginner as well. I'd do it like this:

password=raw_input("Enter the password: ")
times_wrong=0
while times_wrong<3:
if password=="fusion":
print "Welcome! The password is correct, you may enter."
break
else:
print "What is the password?"
times_wrong+=1

As I said before, I only know how to work Python 2. I suppose you'll be able to work out the syntax differences and stuff.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to make a password generator Jankofcik 1 1,555 Aug-06-2023, 01:22 PM
Last Post: deanhystad
  Random Password Generator with Weird Output. Why? Selenestica 2 4,140 Sep-11-2019, 04:36 AM
Last Post: Selenestica
  receive from a generator, send to a generator Skaperen 9 8,572 Feb-05-2018, 06:26 AM
Last Post: Skaperen

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.