[Tutor] Function for converting ints from base10 to base2?

Dick Moores rdm at rcblue.com
Thu Feb 22 06:30:49 CET 2007

At 06:45 PM 2/21/2007, Terry Carroll wrote:

I'm glad to have learned your cool Boolean trick ( sign = 
['','-'][n<0] ), but I think instead I'll try to make

>    sign = '-' if n<0 else ''

a habit.

My thanks to everyone for the feedback about my function, and with my 
question about  sign = ['','-'][n<0]  .

Dick Moores

More information about the Tutor mailing list