Underscores in Python numbers
Peter Hansen
peter at engcorp.com
Sun Nov 20 09:27:28 EST 2005
Dan Bishop wrote:
> Roy Smith wrote:
>>creditCardNumber = myInt ("1234 5678 9012 3456 789")
>
> Or alternatively, you could write:
>
> creditCardNumber = int('1234''5678''9012''3456''789')
Or creditCardNumber = int("1234 5678 9012 3456 789".replace(' ',''))
Or make a little function that does the same job and looks cleaner, if
you need this more than once.
But why would anyone want to create numeric literals for credit card
numbers?
-Peter
More information about the Python-list
mailing list