Python Forum
Why this simple function doesnt work?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why this simple function doesnt work?
#7
def correct(text):
    corrections = {'1':'I', '5':'S'}
    return ''.join(corrections.get(char, char) for char in text)

print(correct("1teruje5z t0"))
Output:
IterujeSz t0
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Why this simple function doesnt work? - by buran - Jan-05-2019, 11:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  print doesnt work in a function ony 2 314 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  Pydoc documentation doesnt work Cosmosso 5 4,396 Nov-25-2023, 11:17 PM
Last Post: vidito
  pip install requests doesnt work misodca 8 6,188 Jul-07-2023, 08:04 AM
Last Post: zyple
  Ldap3 Python print(conn.entries) doesnt work ilknurg 15 5,790 Dec-28-2022, 11:22 AM
Last Post: shad
  I dont know why my function won't work? MehHz2526 3 1,206 Nov-28-2022, 09:32 PM
Last Post: deanhystad
  pip install pystyle doesnt work person_probably 2 2,125 Sep-23-2022, 02:59 PM
Last Post: person_probably
  Why doesnt chunk generation work? LotosProgramer 1 1,953 Apr-02-2022, 08:25 AM
Last Post: deanhystad
  Join dataframes... So simple but I can't work it out! snakes 1 1,375 Oct-27-2021, 09:15 AM
Last Post: snakes
  time function does not work tester_V 4 3,052 Oct-17-2021, 05:48 PM
Last Post: tester_V
  write new function or change the old one to work "smartter? korenron 3 1,990 Aug-09-2021, 10:36 AM
Last Post: jamesaarr

Forum Jump:

User Panel Messages

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