Newbie - Stuck
Gary Herron
gherron at islandtraining.com
Mon Oct 9 15:29:50 EDT 2006
More information about the Python-list mailing list
Mon Oct 9 15:29:50 EDT 2006
- Previous message (by thread): Newbie - Stuck
- Next message (by thread): Newbie - Stuck
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
r3bol at yahoo.com 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 > The error message (which you should have supplied) tells you why it fails. That operator does not operate on strings. In fact, it operates on integers and longs. > I also wondered why this errored as well... > > int(messege) > > Is it not meant to convert a string to a number? > It does convert a string to a number, but just what number do you think "abc" should be converted to ? 42 perhaps? int("123') will yield 123, and if you decide to treat "abc" as a hexadecimal number, then int("abc", 16)" yields 2748. If (as I believe) you wish to take the bit patterns used internally to represent a string and reinterpret those bits as an integer, then ... perhaps you'd like to check out the struct module. Gary Herron
- Previous message (by thread): Newbie - Stuck
- Next message (by thread): Newbie - Stuck
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list