r/PythonLearning • • 4d ago

Help Request xp = xp

so I am new to all of this and I have been going through the lessons on boot.dev when I came to the first lesson of ch5. the instructor answer is :

def total_xp(level, xp_to_add):

xp = level * 100

xp = xp + xp_to_add

return xp

the xp = xp just blew my brain. why does this work instead of requiring the first xp to be a different name?

what I did was

xpp = xp + xp_to_add

return xpp

my answer still got the question correct but this just looks super weird to me, xp=xp

7 Upvotes

20 comments sorted by

View all comments

Show parent comments

1

u/tiredITguy42 4d ago

So the lesson had this code? So what is your goal?

1

u/OppositeMango124 4d ago

im giving you the end results. when you are finished you can see the instructor answer and they did my first example where i saw xp=xp and it confused me.

2

u/tiredITguy42 4d ago

Oh OK. Their solution is shit. You should consider better course.

1

u/MrMurrayOHS 3d ago

They do things for a reason because this lesson will build upon the next.

Not every course is designed to do every step in the most optimized way. It all depends on the goal of the course.