How to remove a specific character from a String in Python

preview_player
Показать описание
This video is a tutorial of how to remove a specific character from a string in Python
Рекомендации по теме
Комментарии
Автор

print("Enter your string")
string = input (str ())
newstring = string.remove('f')
print(str(newstring))

asp
Автор

Thanks! It helped to solve my problem.

igorpokorny
Автор

there are a lot of strings like “ab”, “bc”, ”cd”, ”ad” and u have to find the longest string can be made like ab+bc+cd = abcd = 4(answer) but keep in mind that ending character of first string should be first character of next string. ....can you help with this question

shrastigupta
Автор

But what if the string consists of not just letters, but also symbols and you want to remove the first symbol(which isn't alphanumeric)? For example:
a = string.isalnum()
string= list(string)
b = string[0]
for let in string:
if a == False:
string.remove(b)
return string

It just says:
ValueError: list.remove(x): x not in list

Sasa-yixy
Автор

How can I remove a Text and a number at the same time?

Great_WesternTVFan
Автор

it just removes the first occurrence of the character. how do we remove all the characters ?

piyushraut
Автор

I'm just getting errors after directly copying this.

petrockspiracy
Автор

why is this so un logical .. and hard ..

MADBONE
visit shbcf.ru