Why word in name | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Why word in name

I put one word in name but output from for word in name comes out three times like each letter is a word. but also. how do I check for certain messages without printing it as many times as there are words anyways??? https://code.sololearn.com/cdvUbWVkdFfa/?ref=app

3rd Apr 2018, 3:38 AM
Tristan Barker
Tristan Barker - avatar
8 Respuestas
+ 1
string is array of characters ... So for loop iterate for number of times in list elements. try this https://code.sololearn.com/ch8plgSGnVbJ/?ref=app
3rd Apr 2018, 3:50 AM
Manorama
Manorama - avatar
+ 1
If you change name to a list of str then your code would work the way you expect. Your for loop is currently iterating over each letter or character in the string name. name = ["cat"] Then change your print to: print(word)
3rd Apr 2018, 4:20 AM
ChaoticDawg
ChaoticDawg - avatar
0
what is the dot notation isalpha?
3rd Apr 2018, 4:14 AM
Tristan Barker
Tristan Barker - avatar
0
and thank you!
3rd Apr 2018, 4:14 AM
Tristan Barker
Tristan Barker - avatar
0
Tristan Barker isalpha() returns true if given character is alphabet , otherwise returns false. a="m" a.isalpha() //True a="5" a.isalpha() //False
3rd Apr 2018, 4:27 AM
Manorama
Manorama - avatar
0
thanks you guys! much better than sololearn
3rd Apr 2018, 4:41 AM
Tristan Barker
Tristan Barker - avatar
0
why can I only make one best answer
3rd Apr 2018, 4:41 AM
Tristan Barker
Tristan Barker - avatar
0
you're both the best answer
3rd Apr 2018, 4:41 AM
Tristan Barker
Tristan Barker - avatar