Python Forum
Where did this dictionary come from?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Where did this dictionary come from?
#3
The documentation of maketrans() says it all. If there are two arguments to maketrans(), they must be strings of equal length.

In fact you don't need to understand the table returned by maketrans to use it:
>>> table = str.maketrans("abc", "ABC")
>>> s = "At dawn, if it was low tide on the flats, I would awaken to the chatter of gulls."
>>> s.translate(table)
'At dAwn, if it wAs low tide on the flAts, I would AwAken to the ChAtter of gulls.'
Reply


Messages In This Thread
Where did this dictionary come from? - by Mark17 - Sep-23-2019, 03:47 PM
RE: Where did this dictionary come from? - by buran - Sep-23-2019, 04:13 PM
RE: Where did this dictionary come from? - by Gribouillis - Sep-23-2019, 04:17 PM
RE: Where did this dictionary come from? - by buran - Sep-23-2019, 06:31 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020