Answer the question
In order to leave comments, you need to log in
How to replace all letters 'k' with 'c' and remove numbers from a string?
We need to replace all letters 'k' with 'c' and remove numbers from the string 'Kharchenko Maryna, 1KL, 22'.
name = input('Put your surname, name, group and number of Lab:')
a = name
print(a)
#Зад. 2а - вставить строку "no" между 11 і 12 символом
a1 = print(a[:12], 'no', a[12:], sep='')
#Зад. 2б - заменить все буквы «k» на «c»
#Зад. 2в - убрать все цифры со строки
for i in a:
if i not in {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}:
print(a)
Answer the question
In order to leave comments, you need to log in
''.join(filter(lambda x:not x.isdigit(), 'Kharchenko Maryna, 1KL, 22'.replace('k', 'c')))
# 'Kharchenco Maryna, KL, '
You need to replace all the letters 'k' with 'c'
'abc'.replace('a', 'b')
# 'bbc'
test = 'Hello123'
test = ''.join(x for x in test if not x.isdigit())
# 'Hello'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question