[Tutor] logic ?

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Thu, 4 Oct 2001 15:05:42 -0700 (PDT)


On Thu, 4 Oct 2001, Jerry Lake wrote:

> thank you all for the quick help.
> 
> additionally I'm having issues
> converting the raw input to float
> what I have is as follows
>
> # convert raw input to floating point numbers
> float(x1)
> float(x2)
> float(y1)
> float(y2)

You probably mean:

    x1 = float(x1)
    x2 = float(x2)
    ...

Python's conversion functions don't touch the original values, but they do
give back or "return" values that we can use.  We can capture those values
by reassigning x1.


Python strings are "immutable" --- their contents can't be altered
directly.

###
>>> mystring = "Molecular Biology of the Cell"
>>> mystring[-4] = "B"
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: object doesn't support item assignment
###

This stands in direct contrast with the primitive strings that some other
programming languages provide (although Java does share the same idea of
immutability.)


You'll get it working eventually... *grin*  Good luck!