+ 3

I want find how much words in "I am from Azerbaijan" sentence with Python. How i can do it. please.

question

24th Dec 2017, 7:26 AM
Yunis HĂŒseynzadə
Yunis HĂŒseynzadə - avatar
4 Answers
+ 5
print(len("I am from Azerbaijan".split())) You print the length or the number of elements in a list created from the string by the .split() method. In other words, you count the number of words ;)
24th Dec 2017, 7:31 AM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 6
you can do it dude with out any functions number_word =1 for i in range 'I am from ... ' if i==' ' # ' ' is a space number_word += 1 and if you change the string that you don't sure that is empty or not you can add a if at first program that say if string is empty number_word = 0 good luck 😉
25th Dec 2017, 6:26 AM
‎Hadi
‎Hadi - avatar
+ 3
Dəyməz ;)
24th Dec 2017, 9:30 AM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 2
Thanks
24th Dec 2017, 7:33 AM
Yunis HĂŒseynzadə
Yunis HĂŒseynzadə - avatar