[Tutor] python help!

Peter Otten __peter__ at web.de
Sat Feb 9 20:20:31 CET 2013


Ghadir Ghasemi wrote:

> Hi guys can you tell me what is wrong with the second part of this
> code(elif choice == '2'). When I type something other than 0-255, it
> correctly asks again for an input but when I enter a number from 0-255 it
> does nothing :

It doesn't do nothing, it keeps running the while loop. Add a print() call

>     elif choice == '2':
>          denary2 = int(input("Please enter a denary number: "))
>          remainder = ''
>          while denary2 not in range(0,256):
>              denary2 = int(input("Please enter a denary number: "))
>              continue
>          while denary2 in range(0,256):

              print("XXX denary2 =",  denary2)
              
>             remainder = str(denary2 % 2) + remainder
>             denary2 >>= 1
>          print("The result is",remainder)

to see what's happening.




More information about the Tutor mailing list