NameError: name 'maketrans' is not defined, pythonchallenge
cirfu
circularfunc at yahoo.se
Tue Jun 24 13:55:02 EDT 2008
im doing the python challenge and well, i solved this problem with
ruby :)
phrase = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq
ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr
gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc
spj."
puts phrase .tr('A-XY-Za-xy-z','C-ZA-Bc-za-b')
the answer says to use maketrans but i cant get it to work:
>>> pat = maketrans('A-XY-Za-xy-z', 'C-ZA-Bc-za-b')
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
pat = maketrans('A-XY-Za-xy-z', 'C-ZA-Bc-za-b')
NameError: name 'maketrans' is not defined
>>> "hej tjena tjenixen".maketrans('A-XY-Za-xy-z', 'C-ZA-Bc-za-b')
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
"hej ditt fetto".maketrans('A-XY-Za-xy-z', 'C-ZA-Bc-za-b')
AttributeError: 'str' object has no attribute 'maketrans'
http://docs.python.org/lib/node41.html
More information about the Python-list
mailing list