How can I turn a '1' into a 1..."6" into the number 6?

Hey all - This is for something I might use in my contest entry. How can I turn a string '1' or '2'..etc that I get from the content of a page into an actual number for comparison? I hope Im clear. If not ...Ill expand.

asked 06 Apr '12, 02:51

David%20Henson's gravatar image

David Henson
982310
accept rate: 0%


2 Answers:

Try the int() function. eg.

int('4') * int('3')
>>> 12
link

answered 06 Apr '12, 03:00

JFreegman's gravatar image

JFreegman
4.3k62155

edited 06 Apr '12, 03:01

Holy sweet mary joseph!! Thats it. I knew it was something simple like that. A million thanks

Dave

(06 Apr '12, 03:22) David Henson David%20Henson's gravatar image

May want to try float(<string>) in case it's not an integer, or it's a very large integer ('1e25').

link

answered 06 Apr '12, 05:42

Hobs's gravatar image

Hobs
312420

Your answer
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×15,331
×76
×70
×10

Asked: 06 Apr '12, 02:51

Seen: 330 times

Last updated: 06 Apr '12, 05:42