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
8 Réponses
+ 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
+ 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)
0
what is the dot notation isalpha?
0
and thank you!
0
Tristan Barker
isalpha() returns true if given character is alphabet , otherwise returns false.
a="m"
a.isalpha() //True
a="5"
a.isalpha() //False
0
thanks you guys! much better than sololearn
0
why can I only make one best answer
0
you're both the best answer