[Tutor] Creating an Invalid Message for user

Albert-Jan Roskam fomcl at yahoo.com
Sat Apr 19 17:23:29 CEST 2014



----- Original Message -----

> From: Steven D'Aprano <steve at pearwood.info>
> To: tutor at python.org
> Cc: 
> Sent: Saturday, April 19, 2014 3:58 AM
> Subject: Re: [Tutor] Creating an Invalid Message for user
> 
> Hello Saba, and welcome,
> 
> Saba, unfortunately your email is almost unreadable to me. To me, your 
> code looks like this:
> 
> On Fri, Apr 18, 2014 at 10:19:52PM +0100, Saba Usmani wrote:
> 
>>  print "Welcome to the binary and decimal converter"loop = 
> Truewhile 
>>  loop: bord = raw_input("Enter b for binary or d decimal or exit to 
>>  exit") if bord == "b": d = 0 b = 0 factor = 1; b = raw_input 
> ("Enter 
>>  Binary Number:") b=b.lstrip("0") b = int(b) while(b > 0): 
> if((int(b) % 
>>  10) == 1): d += factor b /= 10 factor = factor * 2 print "The Decimal 
>>  Number is: ", d elif bord == "d": x=0 n=int(input('Enter 
> Decimal 
>>  Number: ')) x=n k=[] # array while (n>0): a=int(float(n%2)) 
>>  k.append(a) n=(n-a)/2 k.append(0) string="" for j in k[::-1]: 
>>  string=string+str(j) print('The binary Number for %d is %s'%(x, 
>>  string)) elif bord == "exit" : print "Goodbye" loop = 
> False
> 
> A complete mess! Unfortunately, I have neither the time nor the 
> inclination to spend a lot of effort trying to unmangle the code to see 
> what you intended it to be.

Hmmm, this indeed looks like Perl. Or worse yet: Brainf*ck, http://www.hevanet.com/cristofd/brainfuck/dbf2c.b ;-)


More information about the Tutor mailing list