Jan-12-2020, 05:33 PM
(Jan-11-2020, 07:45 AM)lummers Wrote:print(letterString.translate({ord(i): "bacon" for i in " ',"}))
The argument to
translate
is a dictionary and is produced by an expression called a dictionary comprehension. Python has comprehensions for other collections too (namely for sets and lists) and a related concept known as generator expressions. I'm giving you the names of these things so you can go and find out more about them.Did you also try looking up the documentation for the
ord
and translate
functions?