To delete none after using def statement in Python

Asked 2 years ago, Updated 2 years ago, 158 views

n = input('Enter string:')
n = n.lower()
n = n.replace(' ','')
n = n.replace('',' ')
n = n.strip()
L = n.split(' ')
S = set(L)
X = list(S)
k = len(X)
def moonchk(n) :
    for i in range(0,k):
        a = X[i]
        print(a, ':', L.count(a))
    return ''
print(moonchk(n))

Enter string: THANKS, thanks!!! ! : 3 k : 2 n : 2 t : 2 h : 2 s : 2 a : 2 , : 1 None

How can I get rid of none?

python def none

2022-09-22 11:40

1 Answers

I think you can fix print(moonchk(n)) to moonchk(n).


2022-09-22 11:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.