Newbie - Stuck

Paddy paddy3118 at
Sun Oct 8 14:51:24 CEST 2006

r3bol at wrote:
> The perl version of this code works but not the python version. What am
> I doing wrong?
> message = "abc"
> password = "z12"
> scrambled = message ^ password
> I also wondered why this errored as well...
> int(messege)
> Is it not meant to convert a string to a number?
Looks like you need to learn more elementary Python before we can even
attempt to help you more, but here goes anyway...

Python has strict typing compared to Perl (a good thing)!
The string "abc" is not a valid representation of an integer in Python,
 and, unlike Perl, Python will complain about its use when an integer
is expected:

$ perl -e 'print "abc" ^ 123, "\n"'

$ python -c 'print "abc" ^ 123'
Traceback (most recent call last):
  File "<string>", line 1, in ?
TypeError: unsupported operand type(s) for ^: 'str' and 'int'


Please don't give up on Python. It *is* different to Perl. 

- Paddy.

More information about the Python-list mailing list