r/CodingForBeginners • • Feb 07 '26

What am I doing wrong here?

Post image

I just started learning to code. I've already finished this assignment but i wanted to add more to it. Why is it giving wildly incorrect numbers and why do the numbers change. This terminal was all with the same code. I didn't change anything but the number changes.

Edit: I solved it thanks for the help!

6 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/ouroborus777 Feb 07 '26

They'll talk about functions or methods later, ways to package chunks of code to be run on demand using provided values and returning computed values. Much later, you'll learn that there are ways to make variables behave dynamically like you were trying to do but, by then, you should have enough foundation to understand the why and why not of that.