Hello comrades, I want to take a character from the input and convert it to a list, and then show the number of repetitions of each index to the user, but it gives an error.
my code:
list = list(input("plase enter keyword"))
for item in list:
print(f"value({item})"+list.count(item))
my error
TypeError
Traceback (most recent call last)
c:\Users\emanull\Desktop\test py\main.py in <cell line: 3>()
2 list = list(input("plase enter keyword"))
4 for item in list:
----> 5 print(f"value({item})"+list.count(item))
TypeError: can only concatenate str (not "int") to str
>Solution :
list_ = list(input("plase enter keyword"))
for item in list_:
print(f"value({item}) {list_.count(item)}")
OR
list_ = list(input("plase enter keyword"))
for item in list_:
print(f"value({item})"+str(list_.count(item)))