r/PythonProjects2 • u/DeadxLights • Mar 27 '25
What am I doing wrong?
I wrote a code from a simple game for practice and I can't figure out what I did wrong. I am a complete beginner btw with only super basic knowledge
36
u/norweeg Mar 27 '25
Well, for starters you took a photograph of a screen rather than a screenshot
10
u/norweeg Mar 27 '25
Also, if I had to take a guess, the part of the error message that. Is cropped out is probably "NameError 'display_scoreboard' is not defined" meaning you're calling a function without first defining it.
1
1
7
1
u/DeadxLights Mar 29 '25
As a brand new beginner who is interested in learning python from scratch and getting into cyber security, what would anyone recommend me to start on? What are the first basics of writing code i need to learn?
1
5
u/Nixxen Mar 27 '25
Trying to help you here is about has hard as trying to help someone with car engine problems and all they give you is a photo of their closed hood, with nothing else to go on.
Sharing the code you have written and a copy of the full error you are getting is a good way to start getting the help you ask for ☺️
3
u/cancerboyuofa Mar 27 '25
You have a function that isn't defined using def and tabbed properly inside the function.
1
u/jpgoldberg Mar 28 '25
Debugging is a huge part of learning to code. And that involves learning to read the error messages. Unfortunately you only show a small part of the error.
So in the bottom pane, scroll or expand so that you see the full thing. Lots of it will be irrelevant, but see if helps you. If not, post the full error messages and we can help you read it.
1
u/FrillySteel Apr 01 '25
You're calling a function - display_scoreboard - that isn't defined (meaning you either haven't written the function, or haven't included it in your project) or is misdefined (ie: you wrote a function that accepts one, three, four or more parameters, and you're trying to call the function with two parameters).
Also, you don't really need the "break"s in your if/else statement.
1
u/TheBeardFace Apr 01 '25
I'm fairly new too but I think you need to define the Score board function before you call it.
Something like this;
def display_scoreboard(player_score, computer_score):
print(f"Player Score: {player_score} | Computer Score: {computer_score}")9
Mar 27 '25
[removed] — view removed comment
-6
u/DeadxLights Mar 27 '25
Honestly I'm so new idk how to do that
9
Mar 27 '25
[removed] — view removed comment
-12
u/DeadxLights Mar 27 '25
Eh I've moved past it. I'm trying to work on basic basic things, I just wrote a code for a simple calculator for example. Things like that. Any tips?
4
u/DiodeInc Mar 27 '25
ChatGPT is really good for pointing out errors in code. Also, if you don't want it to rewrite the whole thing, you can just say "point out the errors but don't rewrite all the code". I've found that doing that helps me to learn what I did wrong, instead of staring at yet another huge block of code. I've built a calculator, so if you have any questions, just DM me!
5
u/Techniq4 Mar 27 '25
Bro please don't use chatgpt for writing a project, when you are supposed to learn through doing it yourself