Life is crazy, i first started watching your python tutorials when i was 15 back when you didn’t even show your face, fast forward 5 years later i got into CS because of you.. now being in my third year of uni and i still come back to your channel for help. You don’t know me but I have a lot to thank you for😭
hey Tim, I am a data analyst struggling with Python but your videos helped me so much to understand how Python works! Thank you so much for sharing! You are a brill teacher!
man you did a fantastic job in this video describing a situation that is difficult to describe (but is not exceedingly complicated, logic wise). You're a talented teacher!
Since building the space invaders game with you 3 months ago and understanding nothing, I now understanding 90% of whats going on here and feel so proud. Thanks Tim!
Thank you so much for this. As someone who knows python but never really kind of mastered it this is really helpful in regaining the confidence in my learnings. Please make more of such projects
Hi Tim. Another solid video and project. I liked it so much and also tried a different way to write the program. I used a binary np array to code the color/position of a guess/target. Then used some mathematical functions to calculate correct/incorrect values. One of the things I really like about coding is the idea that there are many ways to write/solve a problem. With your videos I am learning to write to the point that I can explore different ways. Although, they are not very clean. With time they will be. Thanks for another great video! Looking forward to more!
I replicated the code exactly (exept for using letters A-F instead of colours) and ran into a bug. After checking the correct positions, the second for-loop doesn't know which letters of the guessed code have already been used to find correct positions. Therefore the second loop goes over all letters in the guessed code again and compares them to the remaining actual code letters in the counts dict. If one of the remaining letters is identical to one of the guessed letters in the correct position, it uses that letter again for the incorrect position. Here is an example, because I think my description sucks: If the correct code is ECCD and you guess ECFD, the game prints 3 correct guesses and 1 incorrect guess (which doesn't make any sense). A workaround is to add "if guess_color != real_code" into the if-condition of the second for-loop. I hope this makes some sense lol
Totally digging your new look. Brutal-looking bro with a beard. Yep, you gotta grow a pair, gotta toughen up , gotta hold your ground against ubiquitous Chat Gpt :).
I really enjoy your projects. You are such a blessing for Beginners. I really enjoy your vides so much. I just want to say : THANK YOU SO MUCH FOR SUCH A GREAT CONTENT.
that was a very very good video, thank u for making all of this awesome video. i hope u make more and more of this python projects video ( especially for intermediate level ) because they are very helpful. tnx again tim.
Are you by "competes" referring to "the ability to explain Python in an understandable and comprehensive way" or to "the ability to write very complicated Pyhon code not everyone could write"?
@@andrewtsegaye7330 I didn't say he isn't. But how could such a claim be based on watching the tutorials targeting beginners? For example, how could you tell Einstein is a top scientist afer watching him giving lectures to elementary school students? The other thing I implied is wether you examined some *really* complicated program code. You may take a look at Laplace Transform routines, understanding FFT algorithm, removing echo from sound routines, combining of accelerometer and gyroscope readings in PID loops used in quadcopters (take a look at Betaflight firmware) and similar. Of course, I am talking about programming all these from scratch and optimising the code for special purposes, not simply using some libraries. Or you may take a look at *capture the flag* problems involving Python.
hey guys, someone can help me? i wrote this game with Tim step by step but mine is not running properly it just ask me to enter colors and then says that you must enter 4 color. and it continues like this. can you please help me? i checked my codes and it was exactly like him.
Great tutorial!!! I'm just wondering if there is a way to split the users guesses with the space separator AND if there isn't any space, split by spelling. I've found something like ◽guess = [*guess] ◽but I can't find a way how to make it work with .split(" ")
Somebody please stop me losing my mind.. In lines 34, 39 and elsewhere after; 'real_code' is referenced as a parameter but I have no clue what it's representing. Presumably in line 39 'color' is looping through real_code, but what/where is that!? 😲 At 13:34 I just need a follow up with Why, we 'say' 'real_code' I know it's daft but at this stage, I think (am hoping) a mistake was made, whereby 'real_code' meant to read 'code' (as was generated up at the start). If so it would make sense to me. Otherwise, what are we iterating over, exactly? Thanks in advance to anybody!
Can you make a video about how to 'upgrade' this program? Mabye by making a function to show which color is correct, incorrect or not used. Like the real game....
I hope this message finds you well. I wanted to take a moment to express my deep gratitude for your invaluable contribution to the project. Your efforts have been instrumental in its success, and I am truly grateful for your dedication and hard work. I wanted to let you know that the project has been completed, and it wouldn't have been possible without your expertise and support. Your guidance and input throughout the process have been invaluable, and I am truly grateful for your contributions.
In the generate_code function, I would just write code.append(random.choice(COLORS)) instead of setting the random.choice to a variable then append the variable to code Is there a reason to do it in two lines instead of one? Is it a convention or just to make it easier to explain/change later?
I've learned what I know about python from you, so thank you for that. Is it possible you could do a tutorial for an rpg style text based adventure game in python?
I have been having some trouble with this for some reason. When I try to run it, it tells me the last line where the if __name__ == __main__ line is has an error because game( ) is not defined. any idea on how to fix this issue?
Fun innovative way to torture your prisoners as a Dev in Python! "Let me go, please!" "Yeah, sure let me just program this game real quick... and......... let's play." If they don't get the answer within 10 times..... they 🤐🤐
can anyone give me a piece of advice. My code always works i tried to made this programm myself and i successfully made it but the problem is that my programm is shitty not professional at all
import random COLORS = ['R', 'G', 'B', 'Y', 'W', 'O'] ATTEMPTS = 10 LENGTH = 4 def generate_code(): code = [] for _ in range(LENGTH): code.append(random.choice(COLORS)) return code def guess_code(): while True: guess = input('Enter your guess (e.g., R G B Y): ').upper().split() if len(guess) != LENGTH: print(f'Invalid guess. Please enter a {LENGTH}-color code.') continue for color in guess: if color not in COLORS: print(f'Invalid guess. Please use colors from {COLORS}.') break else: return guess def evaluate_guess(guess, code): color_counter = {} valid_position = 0 invalid_position = 0 for color in code: if color not in color_counter: color_counter[color] = 0 color_counter[color] += 1
# First pass: Count valid positions and decrease the counter for guess_color, real_color in zip(guess, code): if guess_color == real_color: valid_position += 1 color_counter[real_color] -= 1
# Second pass: Count invalid positions without counting already matched colors for guess_color, real_color in zip(guess, code): if guess_color != real_color and guess_color in color_counter and color_counter[guess_color] > 0: invalid_position += 1 color_counter[guess_color] -= 1
return valid_position, invalid_position def game(): print(f"You have {ATTEMPTS} attempts to guess the {LENGTH}-color code.") print('The available colors are: ', ' '.join(COLORS)) code = generate_code() for attempts in range(1, ATTEMPTS + 1): guess = guess_code() valid_position, invalid_position = evaluate_guess(guess, code) print(f'Valid position: {valid_position}. Invalid position: {invalid_position}.') if valid_position == LENGTH: print(f'You guessed the color code in {attempts} attempts!') return else: print('You ran out of attempts. The code was:', ' '.join(code)) if __name__ == '__main__': game()
Hi everyone import random COLOR=['R','G','B','Y','O','W'] tries=10 code_length=4 def generate_code(): code=[] for _ in range(code_length): Color=random.choice(COLOR) code.append(Color) return code code=generate_code() print(code) for i in range(tries): correct_position=0 incorrect_position=0 user_code=input("Guess The code : ").upper() for j in range(len(user_code)): if user_code[j] not in code: pass # print("Correct Position ", correct_position,"|","Incorrect Position : ",incorrect_position) elif user_code[j] in code: # print("Yes") if user_code[j]==code[j]: correct_position+=1 # incorrect_position=0 else: incorrect_position+=1 print("Correct Position ", correct_position,"|","Incorrect Position : ",incorrect_position) if correct_position==4: print("You guessed right!! in {} tries".format(i)) break else : continue Can anybody please tell is this approach of my code correct or not?
As a beginner, some of this goes over my head, but the language is slowly starting to make sense thanks to your videos! Thanks for making them.
Happy to help!
Life is crazy, i first started watching your python tutorials when i was 15 back when you didn’t even show your face, fast forward 5 years later i got into CS because of you.. now being in my third year of uni and i still come back to your channel for help. You don’t know me but I have a lot to thank you for😭
This project is rich with logic and algo that are used to solve interview questions. Highly recommend watching more then once.
hey Tim, I am a data analyst struggling with Python but your videos helped me so much to understand how Python works! Thank you so much for sharing! You are a brill teacher!
you're a legend Tim! what a fun experience i had while doing this...there really is an elegance about programming and oh boy do i love it!
This is a good way to learn. Please keep posting such videos.
man you did a fantastic job in this video describing a situation that is difficult to describe (but is not exceedingly complicated, logic wise). You're a talented teacher!
Since building the space invaders game with you 3 months ago and understanding nothing, I now understanding 90% of whats going on here and feel so proud. Thanks Tim!
Thank you so much for this. As someone who knows python but never really kind of mastered it this is really helpful in regaining the confidence in my learnings. Please make more of such projects
Hi Tim. Another solid video and project. I liked it so much and also tried a different way to write the program. I used a binary np array to code the color/position of a guess/target. Then used some mathematical functions to calculate correct/incorrect values. One of the things I really like about coding is the idea that there are many ways to write/solve a problem. With your videos I am learning to write to the point that I can explore different ways. Although, they are not very clean. With time they will be. Thanks for another great video! Looking forward to more!
Thanks
Thanks so much Tim for all the beneficial videos. Have really learn alot from it.
I replicated the code exactly (exept for using letters A-F instead of colours) and ran into a bug. After checking the correct positions, the second for-loop doesn't know which letters of the guessed code have already been used to find correct positions. Therefore the second loop goes over all letters in the guessed code again and compares them to the remaining actual code letters in the counts dict. If one of the remaining letters is identical to one of the guessed letters in the correct position, it uses that letter again for the incorrect position. Here is an example, because I think my description sucks: If the correct code is ECCD and you guess ECFD, the game prints 3 correct guesses and 1 incorrect guess (which doesn't make any sense). A workaround is to add "if guess_color != real_code" into the if-condition of the second for-loop. I hope this makes some sense lol
Thanks Tim, this content is always useful.
Totally digging your new look. Brutal-looking bro with a beard. Yep, you gotta grow a pair, gotta toughen up , gotta hold your ground against ubiquitous Chat Gpt :).
lmao, exactly why i grew it out ;)
I love you Tim from Tech with Tim
I love these videos, and this is very beginner friendly, but so much of this seems to be done much more difficultly than it needed to be
I can share my equally beginner code if interested?
I’m liking this type short project video because it is more enjoyable to learn programming with projects. hope u will bring more
Love such projects like this! Keep them coming
That’s the plan!
Thanks, you helped me break down this problem for my students. Really appreciate it!
I really enjoy your projects. You are such a blessing for Beginners. I really enjoy your vides so much. I just want to say : THANK YOU SO MUCH FOR SUCH A GREAT CONTENT.
I never knew "else" could be used with a "for" loop. Nice!!
that was a very very good video, thank u for making all of this awesome video.
i hope u make more and more of this python projects video ( especially for intermediate level ) because they are very helpful.
tnx again tim.
Is there anyone that competes with you with python? For me, you're the only one on this planet!
Are you by "competes" referring to "the ability to explain Python in an understandable and comprehensive way" or to "the ability to write very complicated Pyhon code not everyone could write"?
@@ChupoCro Tim is python master! I'm sure that he come back with mind-blowing AI apps like chat-GPT
@@andrewtsegaye7330 I didn't say he isn't. But how could such a claim be based on watching the tutorials targeting beginners? For example, how could you tell Einstein is a top scientist afer watching him giving lectures to elementary school students? The other thing I implied is wether you examined some *really* complicated program code. You may take a look at Laplace Transform routines, understanding FFT algorithm, removing echo from sound routines, combining of accelerometer and gyroscope readings in PID loops used in quadcopters (take a look at Betaflight firmware) and similar. Of course, I am talking about programming all these from scratch and optimising the code for special purposes, not simply using some libraries. Or you may take a look at *capture the flag* problems involving Python.
@@ChupoCro I have worked with him for years nowadays.
Hey Tim, your tutorials is very wonderful, comprehensive and realistic to a beginner like me, thank you for sharing your knowledge to us.. god bless..
No problem! Glad you liked it
Great set of videos, thanks Tim.
You’re starting to look like Walter White
Keep it up, it’s amazing
Now let’s watch the video
Lmao
Bro's the one who knocks
cool example, well explained!
Very interesting project🎉 thank you.
hey guys, someone can help me? i wrote this game with Tim step by step but mine is not running properly it just ask me to enter colors and then says that you must enter 4 color. and it continues like this. can you please help me? i checked my codes and it was exactly like him.
You are amazing my python skills are grow with yoy thank you bro❤
Hi, I think it wasn't required to use zip at line 49. Instead, it could have been done with a simple for loop.
Great tutorial!!!
I'm just wondering if there is a way to split the users guesses with the space separator AND if there isn't any space, split by spelling.
I've found something like ◽guess = [*guess] ◽but I can't find a way how to make it work with .split(" ")
Somebody please stop me losing my mind.. In lines 34, 39 and elsewhere after; 'real_code' is referenced as a parameter but I have no clue what it's representing.
Presumably in line 39 'color' is looping through real_code, but what/where is that!? 😲
At 13:34 I just need a follow up with Why, we 'say' 'real_code'
I know it's daft but at this stage, I think (am hoping) a mistake was made, whereby 'real_code' meant to read 'code' (as was generated up at the start). If so it would make sense to me. Otherwise, what are we iterating over, exactly?
Thanks in advance to anybody!
Can you make a video about how to 'upgrade' this program? Mabye by making a function to show which color is correct, incorrect or not used. Like the real game....
I couldn't find the code for this in your github. I'm struggling with functionality and would like to see the source code to compare.
I would like to add levels to this and each time the length increases. What would be the best way to do that? Make modules?
Very useful content, great work!
I hope this message finds you well. I wanted to take a moment to express my deep gratitude for your invaluable contribution to the project. Your efforts have been instrumental in its success, and I am truly grateful for your dedication and hard work.
I wanted to let you know that the project has been completed, and it wouldn't have been possible without your expertise and support. Your guidance and input throughout the process have been invaluable, and I am truly grateful for your contributions.
It’s awesome .thank you
Great project - Thanks.
In the generate_code function, I would just write code.append(random.choice(COLORS)) instead of setting the random.choice to a variable then append the variable to code
Is there a reason to do it in two lines instead of one? Is it a convention or just to make it easier to explain/change later?
I used random.choices!
No difference at all, just helps with readability
Hey Tim, loved the video! Is there any way to add the curses module into this? I've been stuck on it for quite some time
Tim what is the name of your vscode theme in this video ?
I've learned what I know about python from you, so thank you for that. Is it possible you could do a tutorial for an rpg style text based adventure game in python?
Bro is responsible for me failing college but getting a job as a Py Dev lol
So if you enter any incorrect format answer , EG OOOO, or O O OO, it infinitely loops, how can this be solved?
Hello. Could you make an extension for inkscape, a simple one just for learning?
thank u very much this helped :)
why the last 'else' didn't raise an error ?
I saw this notification while watching your Greedy Algorithms Tutorial😊
im lost...how do you actually run the code. i debugged it. nothing wrong , but it wont actually run. do i need an extension?
you do need a python extention in vscode yes
very useful
I have been having some trouble with this for some reason. When I try to run it, it tells me the last line where the if __name__ == __main__ line is has an error because game( ) is not defined. any idea on how to fix this issue?
Have you made series of python from zero to hero?
Nice video.👍
did everything as shown but correct position wont show in return. Help?
Fun innovative way to torture your prisoners as a Dev in Python!
"Let me go, please!" "Yeah, sure let me just program this game real quick... and......... let's play."
If they don't get the answer within 10 times..... they 🤐🤐
Love you video following from a long time
Great learning project .. where is source code pls😊
Very good explanation
source code?
for me on line 44 it says guess is undefined
Same, did you solve that??
44 line, it says NoneType error
This is like wordle
Got a bit confused coz I kept hearing "cutters" .. figured you were saying colors
I blame my Canadian accent
can anyone give me a piece of advice. My code always works i tried to made this programm myself and i successfully made it but the problem is that my programm is shitty not professional at all
good sir
Bro have been watching u b4 u had a breard
What is the name of your vs code theme
monokai
Hey man, loved the video keep up the good work. but I disliked the transitions for me it was too long.
NİCE MAN
Make project videos with golang
I wish I have more knowledge to build the next big thing.
You can simply extend this to make Wordle!
Tim with beards kkkk
the master of python creating the mastermind game
Should be {TRIES} *tries* instead of just {TRIES}. 50+ comments and noone noticed?
Little bit tweaks and it will become a word guessing game!
Nice video. Not important but for some reason I keep hearing you say "cuthers" instead of colors.
Wait a minute this is false advertisement as the thumbnail has a graphical program
Hey
Pierwszy!
Hold a second, this doesn’t even have a GUI, useless, good effort though
no one prefers python IDLE
None of your projects ever worked for me.
What are u having issues with?
Hey Tim,
Nice Project, a good warmup!
For Generating the Code, we could:
code = random.choices(COLORS, k= CODE_LENGTH) right ?
import random
COLORS = ['R', 'G', 'B', 'Y', 'W', 'O']
ATTEMPTS = 10
LENGTH = 4
def generate_code():
code = []
for _ in range(LENGTH):
code.append(random.choice(COLORS))
return code
def guess_code():
while True:
guess = input('Enter your guess (e.g., R G B Y): ').upper().split()
if len(guess) != LENGTH:
print(f'Invalid guess. Please enter a {LENGTH}-color code.')
continue
for color in guess:
if color not in COLORS:
print(f'Invalid guess. Please use colors from {COLORS}.')
break
else:
return guess
def evaluate_guess(guess, code):
color_counter = {}
valid_position = 0
invalid_position = 0
for color in code:
if color not in color_counter:
color_counter[color] = 0
color_counter[color] += 1
# First pass: Count valid positions and decrease the counter
for guess_color, real_color in zip(guess, code):
if guess_color == real_color:
valid_position += 1
color_counter[real_color] -= 1
# Second pass: Count invalid positions without counting already matched colors
for guess_color, real_color in zip(guess, code):
if guess_color != real_color and guess_color in color_counter and color_counter[guess_color] > 0:
invalid_position += 1
color_counter[guess_color] -= 1
return valid_position, invalid_position
def game():
print(f"You have {ATTEMPTS} attempts to guess the {LENGTH}-color code.")
print('The available colors are: ', ' '.join(COLORS))
code = generate_code()
for attempts in range(1, ATTEMPTS + 1):
guess = guess_code()
valid_position, invalid_position = evaluate_guess(guess, code)
print(f'Valid position: {valid_position}. Invalid position: {invalid_position}.')
if valid_position == LENGTH:
print(f'You guessed the color code in {attempts} attempts!')
return
else:
print('You ran out of attempts. The code was:', ' '.join(code))
if __name__ == '__main__':
game()
Is this how a hacker creates a simple program to guess a password?
Hi everyone
import random
COLOR=['R','G','B','Y','O','W']
tries=10
code_length=4
def generate_code():
code=[]
for _ in range(code_length):
Color=random.choice(COLOR)
code.append(Color)
return code
code=generate_code()
print(code)
for i in range(tries):
correct_position=0
incorrect_position=0
user_code=input("Guess The code : ").upper()
for j in range(len(user_code)):
if user_code[j] not in code:
pass
# print("Correct Position ", correct_position,"|","Incorrect Position : ",incorrect_position)
elif user_code[j] in code:
# print("Yes")
if user_code[j]==code[j]:
correct_position+=1
# incorrect_position=0
else:
incorrect_position+=1
print("Correct Position ", correct_position,"|","Incorrect Position : ",incorrect_position)
if correct_position==4:
print("You guessed right!! in {} tries".format(i))
break
else :
continue
Can anybody please tell is this approach of my code correct or not?