Super awesome tutorial. I took a minute before I watched to think of ways I would do this if it was my own project. I was pleasantly surprised that we thought of the same ways to complete the project! Project Ideas: 1. url shortener 2. Inventory management system (library, grocery store, etc) with sql and simple front end (tkinter, react, etc.) 3. Minesweeper or Galaga with Pygame
This helped me with my assessment so much! I am just learning to code and you explained everything so clearly and perfectly!! Would love to keep seeing videos of yours! Thank you so much for this!
Great tutorial. It took me a little time to see the correlation between the user input changing the default state of has_number and has_special, and how that ultimately influenced what characters the program kept and discarded during the while loop. This tutorial has helped me understand how to break down the 'problem' into much smaller steps. Thanks.
I really love to always watch your tutorial videos because your explanation is well detailed and understandable. As this would help me in building my programming skills in an efficient way
I liked this tutorial, it was easy to follow (i just started learning python). I liked how you explained what you were doing and why. I'd definitely like to follow some other tutorials you create. I also liked how I didn't have to download any extensions to create something.
This Python project creates a password generator that allows users to set a minimum length and include numbers and/or special characters. Key moments: 00:15 This video will guide you through creating a beginner-friendly Python project - a password generator, allowing practice of Python skills and learning new concepts. Additionally, the video offers courses on Python and blockchain development for further learning opportunities. -The project involves creating a password manager with customizable features like setting a minimum length, including special characters, and numbers for dynamic password generation. -The video demonstrates importing modules, defining a function to generate passwords with specified criteria, and organizing characters for password generation. -The process of combining characters into a selection for random password generation is explained, ensuring the generated password meets the specified criteria. 05:17 The video explains how to generate a random password that meets specific criteria by including numbers, special characters, and reaching a minimum length through a loop in Python programming. -Explaining the process of adding numbers and special characters to the password string within the loop. -Setting up variables like 'PWT' for the password and 'meets criteria' to track if the password meets the specified criteria. -Detailing the logic behind updating the 'meets criteria' variable and the approach of starting with 'true' and potentially setting it to 'false' based on conditions. 10:24 The video explains a password generation function using conditional statements to ensure the password meets specific criteria like having numbers and special characters. It iterates to add characters until the criteria are met, then returns the generated password. -Explanation of the conditional statements used to determine if the password meets criteria like having numbers and special characters. It iterates to add characters until the conditions are satisfied. -Demonstration of running the password generation function with manual inputs for minimum length, numbers, and special characters. Showing how the function generates passwords meeting the specified criteria. 15:29 The video demonstrates creating a password generator in Python by taking user inputs for length, including numbers and special characters, then generating and displaying the password. It also addresses a variable naming error and encourages viewers to explore programming and Python further. -The process involves converting user inputs to lowercase, checking for specific criteria, generating a password based on the inputs, and displaying the result. -An error related to a variable naming issue is identified, explained, corrected, and the program is rerun to demonstrate the fix. -The video concludes by suggesting viewers explore programming and Python, offering resources for learning and inviting suggestions for Python projects in the comments. Generated by Aarnav Upadhyay
Hi there, I believe from the function block line 26 change the value of the variable has value at line 18, this variable hold boolean value (T/F). Line 30 we update/change the value of meets criteria to True. Why we repeat to assign a boolean value "True" to a variable meets criteria at line 32 and 34.
This is fun, and for beginners, but seems far more complicated than necessary. Why continue trying to make combinations that have all your elements and checking them; when you can ensure it's all there to start with?
Line#32 is still incorrect. Contains typo for "meets_criteria" I believe because of that typo the code would generate passwords without numbers even if we include numbers in the password.
You don't have really a control on the length of the password generated, it can be (in worst case scenario) : max(len(letters) + len(digits), len(letters) + len(special)) i.e. you can't predict the length of your result password (generated), it's not a good "characteristic" for a security tool ... 🤔
Since I’m the first Tim I hope you see this. I found your videos because of my online CS degree class. Your projects help me build skill because I am struggling a bit with python. There’s so much I don’t understand. Loops are confusing. List and functions don’t make sense. I try to write code for my exercises but I end up going to stack overflow for the answers and it’s never anything I would have though to coding. I have your slot machine game saved to do the walkthrough as a side project and I’ll continue to save more to get some practice in. Thank you for these videos. Currently struggling to build a text based dragon game
@@SpencerMckenithWilliams no i had one intro class that used coral then jumped right into a scripting class using python. I will say I am the most comfortable using python because before I started school I was already familiar with doing very simple things with it. I haven’t used another language yet. I’ve seen them on message boards and python seems to be the most direct and user friendly to me.
_annoying_data_list = [ i * 2 for i in range(9)] List comprehension is shorter syntax but this shouldn't seem confusing? I like doing things this way. Its just me.
@@poboy251 python is more user friendly. I went as far to understand how python memory management works to writing my heavier code with the python C-API. It is quite tedious but rewarding. Especially with subclassing and polymorphism. Still learning as I go along lol
@@SpencerMckenithWilliams ok so walk with me on this. I know what you wrote but however I’m not getting it. Does that makes sense. It’s like I can identify your code because I’ve seen it before but as far as creating something like this myself I’m lost. Your “i” is the data you need to pull from the list multiplied by two specifically the 9th entry in the range I think?? Am I correct.
nice project. but I have a problem with generating a password. all works correct I dont have any error but problem is when i answer on last input with has_special...
Thank you for the amazing tutorial! Loved it, since you used quite some tips which were new to me. Just wanna say, Line 32 has also the same variable name spelling mistake. Will it affect the working of code?
Hey Tim, there is super extreme edge case where random.choice picks all the characters until the min length criteria is met and we end up with a password without numbers or special characters even though the flags may be True.
Very simpler form of this project: import random import string letters = string.ascii_letters numbers = string.digits special_char = string.punctuation character = letters if numbers: character += numbers if special_char: character += special_char password = "" len = int(input("Enter the length: ")) counter = 0 while counter < len: count_pass = random.choice(character) password += count_pass counter += 1 print("Your Password is:" , password) Leave a like so many people can see it.
I'm sorry if i am wrong, but with that code, isn't there will be bug where there is a possibility for a password to be generated without symbol or number even though the user ask for it? So, if i want a password with number, there is a chance that i get a password full of letter because the while loop terminator is only the password length (as long as the minimum length condition fullfiled) which is not what i want.
hello tim thank you so much for you great way of expelling how to create a website(Python Website Full Tutorial - Flask, Authentication, Databases & More) but I want to add forget password and user in the website how to do so? again thank you for your get and hard work I really appreciate it
Unfortunately wirh flask u need to build that in yourself. However, Django does have it pre built if you want to check out it’s auth system, I have some tutorials!
This is probably a silly question- why do the function inputs change between line 5 and line 43? are numbers and special characters set to true in line 5 just to allow them into the character generation portion of the function?
There are no stupid questions man. We are all here to learn :D. I think the way the function arguments are setup was for manually calling it within the code. Basically, you can remove the default values so since the user is required to input arguments for special characters and numbers. I hope this helps and my explanation was bad. :)
Great work - However I would prefere if you could slow down a little bit :) And maybe explain a little more thorough how each components relates to one another - its kinda trycka for a noooooob like me
I quite like this method of testing whether the generated password meets multiple criteria. I would however, change it ju-ust a little bit. Once the password meets the criteria, that's not going to change, is it? There's no need to check if it still meets the criteria after the next character. You have a relevant boolean value at hand (meets_criteria) - trust your previous tests and just use *THAT* to check whether you still need to check the password's validity. So, I'd change the variable name from "meets_criteria" to "criteria_met" and then put all the code from lines 25 - 34 behind an "if not criteria_met:" statement.
If the random func will not generate number because there are less numbers then letters (if you choose pass len=3 for example) code will loop for ever? Or am I missing something?
Hi tim. I have a question . Can we have an AI that learn games and act as a personality test. Like when someone play a game , the AI understand his behavior in the videogame and give results of his personality. If yes , what should we learn in programming to do this ?
Atleast this code is better than a lot of other password generator videos I have seen?, props to you for that, but why would you use random, its not a cryptographically safe random number generator, if you used secrets that would be better.
@@TechWithTim still it would be better if you secrets tbh, that would also promote the good way to create a password gen, still a good video nontheless
@@mistious.8332 well yes, but that isnt the issue, the random module uses a psuedorandom number generator algorithm which is not cryptographically secure ( Mersenne's Twister ) and can be exploited
@@bereck7735 this is a good point! But I think this video is for coding practice for beginners. Not cyber security professionals. I don’t think the average python beginner is thinking about or worried about how exploitable this password generator is while learning the syntax.
Good tutorial but what if someone enters a letter instead of a number in min_len? and when n is allowed in has_number and has_special, the password is not generated from just letters
Hi. Please correct me if I'm wrong. On each iteration, only a character will be chosen from random.choice(characters), yes? Since we've set the default value of has_number and has_special to False, wouldn't meets_criteria will always be fault? I mean, for each loop a character generated from random.choice( ) cannot be both number and punctuation and in the loop, meets_criteria = meets_criteria and has_special. Before that line of code, meets_criteria = has_number was written, so if new_char not in digits then meets_criteria will be False, yes? So if new_char in special and has_special = True, since a number wasn't generated from random.choice( ), has_number will be False and meets_criteria = has_number will in turn affect meets_criteria = meets_criteria and has_special. I'm just really curious and wanted to know. I'm a beginner at Python with no prior programming experience. Your clarification would be very very much appreciated !!
This is cool, but it is *not* secure. The normal Python random library is not designed for security or cryptography, so don't use this to make your real passwords.
Why do you need to set meets_criteria to True before validating with the conditional statements? Whether it starts as True or False, it'll be set to the right Boolean value after the conditional statements no?
Hello it was a great tutorial I really engaged with the way it was explained however even though I copied exactly all in the same way I don't get it to work and I don't understand how does it work that the loop discard and keep characters. Mine is creating more than 10 chars until it complies with the condition can someone please help me understand?
@Tech With Tim is it possible to turn this into a tool so I can distribute the tool, The reason for asking that is account Hijackers are back on the run I have had things happen to me and took me a while to change all passwords. but I think if people changed there passwords once or twice a month they would be more secure then before I have chosen when testing the code the tented minimum length I said 120, how ever when a password has been generated users could copy the code and save it somewhere so they dont forget the code.
это наверное для начинающих совсем совсем начинающих, потому-что код явно излишний, плюс не хватает банальных проверок типа длина не может быть меньше 3 если все опции включены, ну и тому подобное.
I think line 25-28 works just fine. It checks every new character whether it is a letter, digit, or special chars. If the new char is a digit then the first if will become true and has_numbers will be true thus we know that the password at least has a digit. If it not a digit, then the first if will be false, and second elif will be checked, and if it is indeed a special char then has_special will be true thus we know that the password already has at least 1 special char. if the new char is a letter, then we don't really care, because we just want to make sure the password meets the criteria and has minimum length of password. cmiiw 👍
17:56 in if number condition body that spelling is incorrect so how it didn't give you error ? But you fixed the special character body. Sorry its only one month passed I'm learning python with the help of youtube.
Hello everybody, how can we save this password .txt file? I searched google but can't resolve. I was able to try this: with open("Password", "w") as f: f.write("pwd")
Hi Tim, I've completed the code and when i put a minimum length of any number, the password generated is a 1 digit password. Do you know how to fix this?
You guys probably fixed it but just incase, make sure you don't still have the generate_password(10) call that was replaced later in the video. Its always gonna limit to 10 or whatever you have for the parameter.
I made a code to make the password even more random while len(pwd) < length: new_letter = random.choice(letters) new_number = random.choice(numbers) new_symbol = random.choice(symbols) choice = random.randint(0,3) if choice == 1 and has_letters: pwd += new_letter elif choice == 2: pwd += new_number elif choice == 3 and has_symbols: pwd += new_symbol return pwd it generates a random number and based on the number adds either a letter number or a symbol, based on if the user wants or not those in the code. hope it helps someone
import random import string def generate_password(length= 26): # Define the character sets to use in the password letters = string.ascii_letters # 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' digits = string.digits # '0123456789' symbols = string.punctuation # '!@#$%^&*()_+[]{}|;:,.?' # Combine all the character sets all_characters = letters + digits + symbols # Ensure the password has at least one letter, one digit, and one symbol password = [ random.choice(letters), random.choice(digits), random.choice(symbols) ] # Fill the rest of the password length with random characters from all_characters password += random.choices(all_characters, k=length - 3) # Shuffle the characters to ensure the random order random.shuffle(password) # Convert the list to a string and return it return ''.join(password) # Generate a random password with the default length of 12 print("Generated password:", generate_password())
you actually still has the "meets_critera" typo without 'i' in line 32. Because of that even if you don't want numbers, it still shows up just like your last test after fixing the same other typo. That makes me wondering, if in cpp or something that needs to initialize a variable with the data types first, then that typo will become an error which will notice me, but with python that typo is not an error, but a bug that could go unnoticed, how do i prevent this unnoticing typo that become bug in python? Thanks! great tutorial 👍