Problem

Harald Hanche-Olsen hanche at math.ntnu.no
Wed May 19 16:45:15 EDT 1999


+ Frank de Bot <debot at xs4all.nl>:

| How can I calculate with string if they are numbers.
| For example:
| first = 20
| second = 10
| calc = first - second   # This doesn't work.

Works for me:

>>> first = 20
>>> second = 10
>>> calc = first - second
>>> calc
10

| I hope you understand what I try to do.

No I don't - but let me try a wild guess, since you mentioned strings
which are numbers:

>>> first = "20"
>>> second = "10"
>>> int(first)-int(second)
10

Is this what you wanted?  If not, please tell us what you tried, what
you expected, and what you got.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- "There arises from a bad and unapt formation of words
   a wonderful obstruction to the mind."  - Francis Bacon




More information about the Python-list mailing list