DEV Community

Discussion on: Daily Challenge #244 - Search for Letters

Collapse
 
agtoever profile image
agtoever • Edited

Python 3.7

# solution
import string
change = lambda s: "".join(['1' if c in s.lower() else '0' for c in string.ascii_lowercase])

# testcases
for case in ["!!a$%&RgTT", "", "abcdefghijklmnopqrstuvwxyz", "aaaaaaaaaaa"]:
    print(f"change({case}) = {change(case)}")

Try it online!

(Sorry. I didn’t manage for format the code in markdown properly on my iphone)

Collapse
 
peritract profile image
Dan Keefe

I had roughly the same idea:

def isin(text):
  text = text.lower()
  return "".join([str(1)
                  if letter in text
                  else str(0)
                  for letter in "abcdefghhijklmnopqrstuvwxyz"])