+ 5

I need a big hand to tell me how to take string with all characters and remove special characters from it and leave letters only

// user gives us any string character with special characters included to encrypt it num = str (input ()) String1= "abcdefghijklmnopqrstuvwxyz" lengthNum = len(num) lengthstr1 = len(string1) i =0 for num[i] in string1 if

14th Aug 2021, 5:42 PM
Ermias Kebede
Ermias Kebede - avatar
35 ответов
+ 8
Calvin Thomas brilliant 🤣🤣🤣
14th Aug 2021, 7:55 PM
Oma Falk
Oma Falk - avatar
+ 8
Ermias Bibi Here are two possibilities: #1 inp = input() out = "".join(x for x in inp if x.isalpha()) print(out) #2 print(*filter(str.isalpha, input()), sep="") # Hope this helps # Happy coding!
14th Aug 2021, 6:32 PM
Calvin Thomas
Calvin Thomas - avatar
+ 6
Calvin Thomas godfather, genius, mad,sir ... made my day ... very clever ... could u explain please ... please with loops, my teacher wants it... but we sometimes forget that what we think is allday python was magic for ourselves when we made our first steps.
14th Aug 2021, 8:01 PM
Oma Falk
Oma Falk - avatar
+ 6
print("".join(c for c in input() if ord(c) in range(65, 91) or ord(c) in range(97,123)))
15th Aug 2021, 6:51 AM
David Ashton
David Ashton - avatar
+ 3
Ermias Bibi How about using string slicing to reverse the text? :- text[::-1]
14th Aug 2021, 6:37 PM
Calvin Thomas
Calvin Thomas - avatar
+ 3
Calvin Thomas u are not responsible for students or other sololearners. If you like to post the solution then do it. It is a nice snack sometimes. and this one might not be homework.
14th Aug 2021, 8:08 PM
Oma Falk
Oma Falk - avatar
+ 3
Calvin Thomas you know that my whole night is ruined by code challenge losses . Sorry fo the misunderstanding !!!!!
14th Aug 2021, 8:15 PM
Ermias Kebede
Ermias Kebede - avatar
+ 3
# WELCOME TO HAMDAMBEK NOMOZOV's IDEA)) # user gives this word user_str_all = input("Enter your words: ") # this is a key word key_word_that_we_need = input("Enter main word: ") len_user_str_all=len(user_str_all) len_key_word_that_we_need=len(key_word_that_we_need) # we search key word in all word if key_word_that_we_need.find(user_str_all): print("\n -------- success-------\nKeyword is available in word") #in order to clear and understanding we can change key word to * new = user_str_all.replace(key_word_that_we_need,"*") print("Without keyword:"+new) str = list(new) x=-1 print(str) for i in str: x=x+1 if i =="*": print(f"Keyword index position: {x}") else: print("not success")
14th Aug 2021, 9:41 PM
Hamdambek🖥️🎧
Hamdambek🖥️🎧 - avatar
+ 2
Ermias Bibi nope! lets say it was homework. (just as assumption) On the one hand posting homework is not allowed and mods markForDeletion. on the other hand it is a little brainteaser and appeals to be solved. And post solution.... knowing it is not correct. 🤔🤔🤔haaarg lets post
14th Aug 2021, 8:17 PM
Oma Falk
Oma Falk - avatar
+ 2
Ermias Bibi 😭😭😭😭 😂😂😂😂 at least not youe whole life.
14th Aug 2021, 8:19 PM
Oma Falk
Oma Falk - avatar
+ 2
Enter your words: sdfaskkdsada Enter main word: kk ---------- success---- Keyword is available in word Without keyword:sdfas*dsada ['s', 'd', 'f', 'a', 's', '*', 'd', 's', 'a', 'd', 'a'] Keyword index position: 5
14th Aug 2021, 9:42 PM
Hamdambek🖥️🎧
Hamdambek🖥️🎧 - avatar
+ 2
txt = input() txt = "".join([x for x in txt if x.isalpha()])
15th Aug 2021, 11:21 AM
Honorable Con 🇸🇳
Honorable Con 🇸🇳 - avatar
+ 1
Would you show me ?
14th Aug 2021, 6:41 PM
Ermias Kebede
Ermias Kebede - avatar
+ 1
Ermias Bibi I've already shown you.
14th Aug 2021, 6:44 PM
Calvin Thomas
Calvin Thomas - avatar
+ 1
Hahaha big sorry I was so dumb these hours . I lost 500 xp on code challenge
14th Aug 2021, 6:56 PM
Ermias Kebede
Ermias Kebede - avatar
+ 1
When I run your code on the spy life code in sololearn , it couldn't give the right output
14th Aug 2021, 7:20 PM
Ermias Kebede
Ermias Kebede - avatar
+ 1
Calvin Thomas !!! you are brilliant You make my night so bright
14th Aug 2021, 7:29 PM
Ermias Kebede
Ermias Kebede - avatar
+ 1
Oma Falk I don't know what all people tend to say when I give them the solutions. God knows how much of an exaggeration I'd have to face...
14th Aug 2021, 7:56 PM
Calvin Thomas
Calvin Thomas - avatar
+ 1
Oma Falk The Knighthood given by all those gimme-the-solutions-without-making-me-take-a-bit-of-an-effort people makes me feel like a huge hypocrite. I guess that I should stop posting solutions here.
14th Aug 2021, 8:05 PM
Calvin Thomas
Calvin Thomas - avatar
+ 1
Calvin Thomas I think that is hasty generalization to frame us all as hypocrite
14th Aug 2021, 8:07 PM
Ermias Kebede
Ermias Kebede - avatar