question about output

J

Java and Swing

i have printed out some numbers and they look like

10944800e
10952560d

....if i want to later assign this type of number to variable how can i
do it?

for example i can't do...

...since it says "invalid token" on the "e".

thanks.
 
U

utabintarbo

Given that the format is consistent (and the last char is not part of
the number you want), you can probably do something like this:

x = int('10944800e'[:-1])

Disclaimer: I am a n00b. YMMV ;-)
 
S

Steven D'Aprano

i have printed out some numbers and they look like

10944800e
10952560d

They don't look like numbers to me. They have letters at the end. What are
they? What does the letter mean?

...if i want to later assign this type of number to variable how can i
do it?

for example i can't do...


..since it says "invalid token" on the "e".

How did you get the "numbers"? If you just typed them in by hand, then
leave the "e" off and you have a number.

If they are supposed to be hex numbers, then you can use:

x = int("10944800e", 16) # note the quote marks
print x

-> 4450451470

If you don't care about the numeric value, then you just put quote marks
around the number+letter:

x = "10944800e"

but then x will be a string, not a number.

If none of these answers is what you need, you will need to explain your
problem a little better.
 
D

Dennis Lee Bieber

i have printed out some numbers and they look like

10944800e
10952560d
What did you use to print them out -- that will tell us how to read
them...

For example, if the above had a 0 behind the "e" or "d"...
Traceback (most recent call last):

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,008
Latest member
KieraMcGuf

Latest Threads

Top