How do I write a code for example from "foo" to exclude just the letter "o"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11

How do I write a code for example from "foo" to exclude just the letter "o"?

https://code.sololearn.com/cf0HJL50Xcir/?ref=app

12th Mar 2018, 10:54 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
2 Answers
+ 4
xy = {1, 2, 1, 3, 1, 4, 5, 6,"foo"} print(xy) xy.add(-7) xy.remove(3) for item in xy: if isinstance(item, str): if "o" in item: newitem = item.replace("o", "") xy.remove(item) xy.add(newitem) print(xy)
12th Mar 2018, 11:04 PM
Pedro Demingos
Pedro Demingos - avatar
+ 1
a = "foo" print(a.replace("o", ""))
13th Mar 2018, 3:18 PM
Markus Kaleton
Markus Kaleton - avatar