import this
whatiszenofpython= "".join([c in this.d and this.d[c] or c for c in this.s])

Specialties:
IT/Science/Contracts/Religious translation/interpreting FIN-ENG-FIN
Python programming

3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by pyTony
0

Did my own version (generator and string concatenation):

import this ## prints zenofpython
print '-'*70
whatiszenofpython = "".join(this.d[c] if c in this.d else c for c in this.s)
zen = ''
for c in this.s:
    zen += this.d[c] if c in this.d else c
print zen

Edited by pyTony: n/a

0

It is same as mine.. But I produce default value with logical operations or if..else instead of using default parameter of get. It is handy to remember the get alternative, of course.

Edited by pyTony: n/a

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.