Комментарии:
Thankss
ОтветитьIn my pc ..the problem only runs for one time ..How to handle that without using while true
ОтветитьFantastic🥂
Ответитьwhats plen
Ответитьwhile True:
plen = input("Enter the length of password: ")
if plen.isdigit():
plen = int(plen)
break
else:
print("Invalid Input")
Why you use ascii in lower and upper and not in digit
Ответитьplen = input("Enter password length\n")
if plen.isdigit() == True:
plen = int(plen)
print("Your password is: ")
print("".join(random.sample(s, plen)))
else:
print("Please enter only digits")
Suggestions:
1. You can use list(string.printables) instead of that much extend functions
2. These passwords are not practical. Use list(string.ascii_letters+string.digits)
handling gibberish
pattern = re.compile("[0-9]+")
if pattern.fullmatch(plen) is not None:
plen = int(plen)
else:
print("Enter number")
first i watched your python 15 hour course after this i started follow you😍
Ответитьi love this project
Ответитьint(input("Enter length of password and in only in number"))
this will ur answer
what if we get the password only in symbols?
ОтветитьSir maximum length kitni ho skti h isme
ОтветитьYou can handle gibbrish using try and except
you can use:
try:
plen = int(input("Enter the password length:\n"))
except:
sys.exit("Invalid Length")
but first of all you have to import the sys module so that you can exit it
Thx code with harry for helping us in the journey of learning this beautiful language....
bhaiya is tarike se to user ko khod hacker hair karna padega
ОтветитьFinally a tutorial without import random
Ответитьimport string as st
import random as r
if __name__=="__main__":
s1=list(st.ascii_lowercase)
s2=list(st.ascii_uppercase)
s3=list(st.digits)
s4=['#', '$', '%', '&','@']
passlen=input('Enter length of password \n')
# if plen >= '0' and plen <=9:
# plen=plen(int)
if passlen in st.digits:
passlen = int(passlen)
c=[]
c.extend(s1)
c.extend(s2)
c.extend(s3)
c.extend(s4)
print('Your password is \n')
# r.shuffle(c)
# print(''.join(c[0:passlen]))
print(''.join(r.sample(c,passlen)))
else:
print('Please enter valid input \
LENGTH OF PASSWORD should be a number...')
print("".join(random.shuffle(list(s1+s2+s3+s4)))[0:64]) = 64 chr len random str.
Ответитьthanks sir helps alot in working
ОтветитьSir how to remove greater than and less then symbol from password?
ОтветитьEval type casting can change
Ответитьharry bhai while loop chlake check kr lenge.
if plen.isdigit():
print("".join(random.sample(s, int(plen))))
break
else:
print("enter a valid number : ")
continue
Sir kis bhi wifi password kaise pata kare
ОтветитьBro you are awesome.... loved your explanation \m/
Ответитьvery good Harry Kumar!
ОтветитьError ke caught karne ke liye extension handling ka istamal karna hoga while flag == True laga ke usme try: aur excend dalna padega.
Ответитьharry bhai notes download karne mai masla ho raha hai ye error hai Application error: a client-side exception has occurred (see the browser console for more information).
Ответить❤️❤️
ОтветитьYou can do this without the string module and only by random module to give you random password :
import random
# Random Password Generator in Python
import random
try:
list1 = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",1,2,3,4,5,6,7,8,9,"!","@","#","$","%","^","&","*","(",")"]
random.shuffle(list1)
user_input = int(input("Enter the length of the password: "))
password = []
for i in range(user_input):
password.append(random.choice(list1))
random.shuffle(password)
join = ''.join(map(str, password))
print(join)
except:
print("You have entered an invalid state for an integer !\n")
print("Please enter an integer as your length for the password you desire\n")
*This is a fully functional code written by me and you can use it too*
Thanks!
Tried to fix the bug, using length of input characters, except input as integers. Using if-else statements
Thanks for the project, to learn...
first of all i really really want to tanks to you for everything that i learn from you.
I haven't watched all of your videos but when ever i watch you videos i really learn something you.
sir i have a question that to be a hacker. what should i learn for hacking
Really u are great. I always follow ur YT. Thank u for ur advices.
Ответитьthankyouu
ОтветитьTq so much sir 🥰
Ответить👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍
Ответитьkya hI
Ответить# Password Generator
import string
import random
s1= string.ascii_lowercase
s2= string.ascii_uppercase
s3= string.digits
s4= string.punctuation
plen=int(input("Enter Password Length:"))
s=[]
s.extend(list(s1))
s.extend(list(s2))
s.extend(list(s3))
s.extend(list(s4))
# print(s)
random.shuffle(s)
# print(s)
a=[]
for i in range(plen):
a.append(random.choice(s))
print(f"Password:{''.join(a)}")
print(f"Password:{''.join(random.sample(s,plen))}")
U r the best teacher
ОтветитьSir aap 2 million subs ke karib ho 😄
Ответитьimport string
import random
try:
x = int(input('What should be the length of your password:\n'))
def Password_generator(num):
set_1 = string.ascii_uppercase
set_2 = string.ascii_lowercase
set_3 = string.punctuation
set_4 = string.digits
s = []
s.extend(list(set_1))
s.extend(list(set_2))
s.extend(list(set_3))
s.extend(list(set_4))
random.shuffle(s)
print('Your password is:', "".join(s[0:num]))
Password_generator(x)
except ValueError:
print('Input is incorrect...please try again')
ValueError: invalid literal for int() with base 10:
Ответитьimport string
import random
if _name_ == '__main__':
s1=string.ascii_lowercase
s2=string.ascii_uppercase
s3=string.digits
s4=string.punctuation
while True:
try:
plen=int(input("enter password lenghth:"))
s=[]
s.extend(list(s1))
s.extend(list(s2))
s.extend(list(s3))
s.extend(list(s4))
random.shuffle(s)
print("your password is:")
print("".join(s[0:plen]))
break
except Exception as e:
print(e)import string
import random
if _name_ == '__main__':
s1=string.ascii_lowercase
s2=string.ascii_uppercase
s3=string.digits
s4=string.punctuation
while True:
try:
plen=int(input("enter password lenghth:"))
s=[]
s.extend(list(s1))
s.extend(list(s2))
s.extend(list(s3))
s.extend(list(s4))
random.shuffle(s)
print("your password is:")
print("".join(s[0:plen]))
break
except Exception as e:
print(e)
@
CodeWithHarry
generate a password using a given field (like First name, Last name, Date of birth ) length of 6+
Sir this is not working in mobile , python ide pydroid.
ОтветитьHow can one remember such complex passwords
Ответитьimport random
import string
def check_int(s):
if s[0] == '-':
return False
elif s[0] in [0,1,2,3,4,5,6,7,8,9]:
return s.isdigit()
return s.isdigit()
s1 = string.ascii_lowercase
s2 = string.ascii_uppercase
s3 = string.digits
s4 = string.punctuation
s0 = s1 + s2 + s3 + s4
s = ""
while True:
length = input("enter password length (minimum length is 4): ")
if check_int(length):
length = int(length)
break
else:
print('length can only be a positive integer')
s += random.choice(s1) + random.choice(s2) + random.choice(s3) + random.choice(s4)
for i in range(length):
s += random.choice(s0)
while True:
print(''.join(random.sample(s,len(s))))
input()