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.


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
  • [Tutor] pytho... Ghadir Ghasemi
    • Re: [Tut... Peter Otten
      • Re: ... D . V . N . Sarma డి . వి . ఎన్ . శర్మ
        • ... D . V . N . Sarma డి . వి . ఎన్ . శర్మ

Reply via email to