+ 1

i need help in python more precisely advise. I'm making code with input and i only need natural numbers.

how can i determine only natural nambers with if . idea is that when user types number he/she will get binary as an output, but there is an probably of making error with just wrong type input.

7th Oct 2020, 9:17 PM
Luka Maghlaperidze
Luka Maghlaperidze - avatar
2 Respostas
+ 5
if type(a)==int and a>0 or you can use try/except
7th Oct 2020, 9:31 PM
Julia Shabanova
Julia Shabanova - avatar
7th Oct 2020, 11:07 PM
Mohammad Hosein Nosrati
Mohammad Hosein Nosrati - avatar