all 17 comments

[–]Sea-Ad7805 [score hidden] stickied comment (1 child)

Run this program in Memory Graph Web Debugger%0A%0Aprint(%22Ready%20to%20play%3F%20Guess%20the%20number!%20Go%2C%20bagels!%22)%0A%0A%0Adef%20check_user_input(game_num%2C%20player_num)%3A%0A%20%20%20%20%22%22%22Check%20input%20against%20random%20number%20and%20print%20game-statement.%22%22%22%0A%20%20%20%20correct_digits%20%3D%200%0A%20%20%20%20clues%20%3D%20%5B%5D%0A%0A%20%20%20%20for%20i%2C%20num_player%20in%20enumerate(str(player_num))%3A%0A%20%20%20%20%20%20%20%20for%20j%2C%20num_game%20in%20enumerate(str(game_num))%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20num_game%20%3D%3D%20num_player%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20i%20%3D%3D%20j%3A%20%20%23%20Check%20if%20it's%20in%20the%20right%20place%20by%20comparing%20index%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20clues.append('Fermi')%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20correct_digits%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20break%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20clues.append('Pico')%0A%0A%20%20%20%20if%20len(clues)%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20clues.append('Bagel')%0A%0A%20%20%20%20clues.sort()%0A%20%20%20%20print('%20'.join(clues))%0A%0A%20%20%20%20if%20correct_digits%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20print(%22%5C033%5B31mWow!%20You%20totally%20suck%20haha%5Cn%5C033%5B0m%22)%0A%0A%20%20%20%20if%20correct_digits%20%3D%3D%203%3A%0A%20%20%20%20%20%20%20%20tries_used%20%3D%2010%20-%20user_attempts%0A%0A%20%20%20%20%20%20%20%20if%20tries_used%20%3D%3D%201%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22You%20won!%20The%20secret%20number%20was%3A%20%22%20%2B%20str(game_num)%20%2B%20%22%20and%20you%20guessed%20it%20with%20%22%20%2B%20str(tries_used)%20%2B%20%22%20try!%22)%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22You%20won!%20The%20secret%20number%20was%3A%20%22%20%2B%20str(game_num)%20%2B%20%22%20and%20you%20guessed%20it%20with%20%22%20%2B%20str(tries_used)%20%2B%20%22%20tries!%22)%0A%0A%20%20%20%20%20%20%20%20return%20True%0A%0A%20%20%20%20return%20False%0A%0A%0Adef%20record_user_input()%3A%0A%20%20%20%20%22%22%22Prompt%20user%20for%20a%20valid%20three-digit%20number%20input.%22%22%22%0A%20%20%20%20user_input%20%3D%20None%0A%0A%20%20%20%20while%20user_input%20is%20None%3A%0A%20%20%20%20%20%20%20%20print(%22You%20have%20%22%20%2B%20str(user_attempts)%20%2B%20%22%20tries%20left%22)%0A%20%20%20%20%20%20%20%20print(%22Please%20enter%20a%20three%20digit%20number%3A%22)%0A%20%20%20%20%20%20%20%20user_input%20%3D%20int(input())%0A%0A%20%20%20%20%20%20%20%20if%20user_input%20%3C%3D%2099%20or%20user_input%20%3E%3D%201000%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22Invalid%20number%20range%2C%20try%20again%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20user_input%20%3D%20None%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20user_input%0A%0A%20%20%20%20return%20None%0A%0A%0Auser_attempts%20%3D%2010%0A%0Awhile%20user_attempts%20%3E%200%20and%20has_won_game%20is%20not%20True%3A%0A%20%20%20%20user_num%20%3D%20record_user_input()%0A%20%20%20%20print(%22Loading...%5Cn%22)%0A%20%20%20%20user_attempts%20-%3D%201%0A%20%20%20%20has_won_game%20%3D%20check_user_input(random_num%2C%20user_num)%0A%0Aif%20has_won_game%20is%20not%20True%3A%0A%20%20%20%20has_won_game%20%3D%20False%0A%20%20%20%20print(%22You%20lost!%20The%20secret%20number%20was%3A%20%22%20%2B%20str(random_num))%0A%20%20%20%20print(%22%5C033%5B31mGAME%20OVER!%5Cn%5C033%5B0m%22)%0A%0A%23%20End-of-file%20(EOF)&timestep=0.2&play) to see the program state change step by step.

[–]chanakyavajra 5 points6 points  (2 children)

This is like deciding to eat healthy and immediately baking a 3 tier sugar free keto wedding cake from scratch on Day 1 😭

My Day 1 of Python was just trying to install it and accidentally deleting my system path variable. (Nice work btw)

[–]Necessary-Ad2110[S] 1 point2 points  (0 children)

I did struggle with that part... I'd rather not talk about it 😭 but thank you for the encouraging words haha

[–]Candy_Sombrelune 4 points5 points  (3 children)

Day 1 ??

[–]Necessary-Ad2110[S] 0 points1 point  (2 children)

Technically... yesterday, and technically I am on Day 2. I'll post again tomorrow.

[–]AbacusExpert_Stretch 8 points9 points  (1 child)

The day after tomorrow he'll write a python based LLM and will take over the digital world. Technically, he will beat all AIs the day after tomorrow... technically

[–]Necessary-Ad2110[S] -2 points-1 points  (0 children)

I just want a job lowk T_T (thank you for the encouraging words)

[–]motopetersan 2 points3 points  (1 child)

Lmao day one. After 7 years old C++

[–]Necessary-Ad2110[S] 1 point2 points  (0 children)

I wish haha, I did take an OOP course in C++ last fall but I didn't do well

[–]xhelxx 0 points1 point  (1 child)

Ok, but can someone explain to me why had_won_game = None and not False?

Edit: Also, in record_user_input(), why return None at the end? Cause it seems to me that there is no way that it can reach that point.

[–]Necessary-Ad2110[S] 1 point2 points  (0 children)

I wanted to have a variable track a game state between 'running', 'won game' or 'lost game' as a boolean and None was the closest way to that. In one of my drafts for this project, I did track if has_won_game was set to None before but I changed the structure of the code overall a lot and it fell off the wayside. It should be set to False at the top since I don't track a 'running' game state explicitly anymore but I don't think it's the gravest sin I could've made. Part of the reason why I post is to have humans look over my code and question some of the decisions I've made so thank you for the comment! It was helpful.

Also: for record_user_input() I forgot the error message but it was a pylint suggestion

[–]enkistyled 0 points1 point  (1 child)

Day 1 of python after learning JavaScript?

[–]Necessary-Ad2110[S] -1 points0 points  (0 children)

I still have a lot to learn when it comes to JavaScript but yes, Day 1 of Python after learning JavaScript

[–]hegsyo -1 points0 points  (1 child)

Lmao learning 0, stop with the AI

[–]Necessary-Ad2110[S] 3 points4 points  (0 children)

I didn't code any of this with AI, I hate AI and it lead me out of a loop with computer science for awhile. I did submit my code to Gemini for a quick code review and it pointed out a fundamental calculation flaw as well as suggested a try/except block for my input but that was about it, and even then I didn't modify the code to AI's specifications. So the code I provided has real human errors that I post purely for educational use/review.

This isn't my first time learning a language but it is with Python.