Ask coding questions

← Back to all posts
i made a weight converter!
AbdulrahmanDarw

how do i restrict it so they can only input a certain thing like l or k, anyways how bad was it?

Voters
AbdulrahmanDarw
Comments
hotnewtop
Coder100

You can't exactly, maybe you could use the getkey module to change user input.

In general, having an error message is helpful, and certainly won't hurt.
https://pypi.org/project/getkey/

AbdulrahmanDarw

@Coder100 ok thanks il look into it i have another question tho why does int have to be before the input?

Coder100

because you want to convert it into an int.
otherwise you would turn the string to print to the console into an int and that is not what you want

remember pemdas?
this is what it is @AbdulrahmanDarw

FloCal35

I don’t think you can