print("This is a conversion program from pounds(lb) to kilograms(kg) and vice versa")
try:
weight = float(input("Enter your weight please:"))
except ValueError:
print("Please enter a valid number, thank you.")
exit()
unit = input("Please enter the unit ( lb/kg ):")
if unit == "lb":
result = round(weight / 2.2046, 3)
print(f"{weight} pounds correspond to {result} kilograms")
elif unit == "kg":
result = round(weight * 2.2046, 3)
print(f"{weight} kilograms corresponds to {result} pounds")
else:
print("Please enter a valid unit.")
#๐ What do y'all think of my code ?
89 messages ยท Page 1 of 1 (latest)
@gleaming jewel
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.
Closes after a period of inactivity, or when you send !close.
thx to brocode tbh
look into while loops
right now i just wanted to prove a point to my brother
but ima do that in the futur
it's fine
and tbh, i just took BroCode's code (from his "Python weight conversion exercise ๐๏ธ" video) and tried to make it better
and hey, i think i didn't do a terrible job, quite good in my opinion
it works just fine
I'd say do unit.lower()
great code op but during the input when the user enters a string or something else which isnt a float it end the program u can improve it by asking for the input again instead
just in case someone types in KG or something
i can do that,yeah
what does that do ?
and for the unit too
"KG" -> "kg"
converts it to all lowercase
lowercase
yep
yeah
just add a .lower() to the end of your unit input section
thx !
do i do that : unit = input("Please enter the unit ( lb/kg ):").unit() ?
or did i just not understand ?
cuz when i do that here is the warning i got :
I was saying more like : unit = input("Please enter the unit ( lb/kg ):").lower()
oh crap i typed unit instead dof lower
now it's a complytely different error
tf does it mean name expected
huh
it resolved itself
it's soooo cool
it works even better now !
np, have fun with python
im in the middle of making a game
looks like this so far
well, i hope ur having fun too !
thx!
it look really cool
thanks man
it looks like a car lol, but what is it ?
I would send a video of it, but I can't in here
discord isn't really made to send video
It's just this server specifically, it doesn't allow it
damn it's cool
thx
the semi 3d is really well done
i can see the car inside the sidewalk time to times, is it possible to fall of ?
it's literaly inside the sidewalk
you cant drive through it, the collison is just in the wrong spot
its still super early stages
it's still cool
thanks
is gyazo the game ?
gyazo is just what i used to record it
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.