why the inconsistency?
bignose-hates-spam at and-benfinney-does-too.id.au
Wed Sep 24 03:02:00 CEST 2003
On 23 Sep 2003 18:04:33 -0700, mensanator wrote:
>>>> print len(`2**64`)
> But the correct answer is 20, not 21. The reason the
> answer is wrong
>>>> print `2**64`
> Why is the "L" there? I thought "L" isn't used anymore?
You want to perform two operations; make them explicit.
# Convert number to string representation
foo = "%d" % ( 2**64 )
# Get length of string
print len( foo )
As you've pointed out, a number has no inherent string representation
(and thus no length); choose one explicitly (e.g. by string formatting).
\ "I bought a dog the other day. I named him Stay. It's fun to |
`\ call him. 'Come here, Stay! Come here, Stay!' He went insane. |
_o__) Now he just ignores me and keeps typing." -- Steven Wright |
Ben Finney <http://bignose.squidly.org/>
More information about the Python-list