Python

Geoff Gerrietts geoff at gerrietts.net
Thu Feb 6 22:43:09 EST 2003


Quoting Uri (phrogeeb at hotmail.com):
> My problem is that r is a percentage (in my program, I tell the user
> to represent 4% as .04).  When I run the program, it says that there's
> no way to deal with a double or something to that effect. But I also
> read that there's no way to type a variable, that they are
> "dynamically typed". Well, that doesn't work here.
> 
> So, what do I do?

Dynamically typed means something different from what you think it
does.

  r = input("r?")

  # r is now of type string
  
  r = float(r)

  # r is now of type float

That's what you want to do. :)

--G.

-- 
Geoff Gerrietts             "A little sincerity is a dangerous thing, 
geoff @ gerrietts.net        and a great deal of it is absolutely fatal." 
http://www.gerrietts.net/                           --Oscar Wilde





More information about the Python-list mailing list