#๐ weird issue when i try executing my code
141 messages ยท Page 1 of 1 (latest)
@lethal gyro
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
I mentioned before you should really avoid spaces in filenames
dude
no
this issue is weird
its not related to my code i think
Can you show your pycharm window?
dm me
No, please don't DM me. If you have any questions about python, you can ask it here
how do i show u my screen
take a screenshot
k
You can share screenshots here
I don't see a file with V2 in the name
oh i fixed it...
sounds like an old file that you deleted
i did current file and it showed me the error
I prob mixed em
current file fixes
i reversed it or sum again lol
ok
weight_choice = float(input("Enter your weight: "))
unit_choice = input("Which unit do you want to choose (KG OR LBS): ")
if unit_choice == "KG":
weight_choice == weight_choice*2.205
print(weight_choice)
elif weight_choice == "LBS":
weight_choice == weight_choice/2.205
print(weight_choice)
does it look fine
@spiral moss
I mentioned previously that you shouldn't reuse the weight_choice variable for the new result
make a new variable
and I thought you were going to try and add a loop to it?
i wanted to finish this first
so i dont get confused too much
the elif result?
your variable weight_choice is the name you use for the input, but then you also use it for the converted result
so you're overwriting the old data
now you have no way of ever displaying to the user what their original value was
if you create a new variable, then you'll have more information
but if i dont use the weight_choice variable to convert which i used in input then how will the code know what variable im using
OHH WAIT
Oh yes
new variable
ok
If I were to create a new variable, what string would be in it
why would a string be in it?
It would be the result of your conversion
instead of reassigning it back to weight_choice, make a new variable
isn't a variable this?
weight_choice = ""
why does it have to be a string?
Um
weight_choice == weight_choice*2.205
yeah
right now you're doing this for your conversion
I'm saying don't use the name weight_choice here
weight_choice = float(input("Enter your weight: "))
you're already using that name here
don't reuse the same name
So i create a new variable
weight_choice_two
pick a meaningful name
i suck at that
what does this line do?
I also just realized you're using == here
it should be =
If I don't reuse py weight_choice
when doing py weight_choice = weight_choice*2.205
How would I multiply the weight with 2.205
why?
he can just rewrite the variable
it gives error
sure, but if you want to improve on the code by printing a message saying something involving their original weight, you can't
If the meaning of a variable has changed, it's best to use a different name
weight_choice = weight_choice_two*2.205
this?

i mean right
the multiplication is in the right side
the right side of the = is always evaluated first
ye i suck at left right
then assigned to whatever is on the left of the =
lol
weight_choice = float(input("Enter your weight: "))
unit_choice = input("Which unit do you want to choose (KG OR LBS): ")
if unit_choice == "KG":
weight_choice_two = weight_choice*2.205
print(weight_choice)
elif weight_choice == "LBS":
weight_choice_two = weight_choice/2.205
print(weight_choice)
This right?
Think i got it right
k
theres a problem
yea trye
when i type weight 24
what?
use int(weight)
that's not the issue
it removers the .0 from numbers
.
um
you've made a new variable
that's what you should be printing
also use a better name like converted_weight
oh yeah
oooh
i always forget small details
weight_choice = float(input("Enter your weight: "))
unit_choice = input("Which unit do you want to choose (KG OR LBS): ")
if unit_choice == "KG":
converted_weight = weight_choice*2.205
elif weight_choice == "LBS":
converted_weight = weight_choice/2.205
print(converted_weight) # Only one print needed
check DMs later @lethal gyro
It's important not to rush. If you make a mistake, it's ok, but take a moment to look it over
Learning how to debug your code is an important skill to practice
and if you only rely on others to solve your mistakes, you'll never learn
debug meaning?
fix the errors
"figure out what's wrong with your code"
OH GOT SMTH IS WRONG AGAIN
k
think about what each line does
think about if something isn't where it should be
think about what each variable represents
you can use extra prints to see what certain variable's values are
and see if they're what you expect
fixed it
I was multiplying 2.205 on the first conversion i had to divide
i gotta go somewhere i be back in 10 mins and then ima try the loop
k back
gotta eat now xd
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.