Liste kavramalarını biliyorum, sözlükle ilgili ne anlama geliyor?Python'da sözlük anlaşmaları var mı? (Dict dönen fonksiyonla ilgili problem)
Beklenen Çıktı:
>>> countChar('google')
{'e': 1, 'g': 2, 'l': 1, 'o': 2}
>>> countLetters('apple')
{'a': 1, 'e': 1, 'l': 1, 'p': 2}
>>> countLetters('')
{}
Kodu (Ben bir acemi değilim):
def countChar(word):
l = []
#get a list from word
for c in word: l.append(c)
sortedList = sorted(l)
uniqueSet = set(sortedList)
return {item:word.count(item) for item in uniqueSet }
bu kodla problemi nedir? Neden bu SyntaxError
'u aldım?
return { item:word.count(item) for item in uniqueSet }
^
SyntaxError: invalid syntax
sözdizimi hatası ')' ekstra: –
corrected.but hala sorunlar var 'word.count (madde))' – newbie
y Can aldığınız asıl hatayı yapıştırın mı? – SingleNegationElimination