Forum Archive

AttributeError: module 'string' has no attribute 'maketrans'

gbb

I am trying to use the maketrans method, and I can’t seem to get it to work in 3.6. I copied the code exactly from this link: https://forum.omz-software.com/topic/3062/string-maketrans-method-not-working.

If I run the code in 2.7, it works fine. If I run it in 3.6, after updating the print command for 3.6 (encapsulating what follows ‘print’ within parentheses), I get the attribute error within the subject line. Any guidance for me?

mikael

@gbb, it should be str, not string.

ccc

https://stackoverflow.com/questions/41535571/how-to-explain-the-str-maketrans-function-in-python-3-6/41536036