0

Why did i get type error

I want to create a data frame This part of the code work. def vowels(a): L=a.split() for i in L: print(i.count('a')+i.count('e')+i.count('i')+i.count('o')+i.count('u') a=" this is good" ""This part not working properly import pandas as pd df=pd.DataFrame({'vo':list(vowels(a)}) print(df) "" I want like this vo 0. 1 1. 1 2. 2

3rd Nov 2019, 3:14 PM
Nandakumar TS
Nandakumar TS - avatar
3 Réponses
+ 3
You can also try this: inp = input('enter text: ') for i in 'aeiou': print(f'{i}, {inp.count(i)}') I recommend you to go throuhh the python tutorial in SoloLearn. The code you presented here is not very promising.
3rd Nov 2019, 8:24 PM
Lothar
Lothar - avatar
+ 2
Because your function isn't returning anything. Store the vowels count in a list and return that. vowels_counts = [] for i in L: vowels_counts.append(i.count('a')+i.count('e')+i.count('i')+i.count('o')+i.count('u')) return vowels_counts
3rd Nov 2019, 4:18 PM
R_3-dr
R_3-dr - avatar
+ 1
You should use function generators. https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2462/ Only replace 'print' in function vowels with 'yield'. Also care about parentheses.
4th Nov 2019, 7:13 AM
reza