У меня проблемы с этим кодом:
return render(request, 'count.html',{'fulltext':fulltext,'count':len(wordlist),'worddictionary':worddictionary.items("")})
CMD сообщает мне неверный синтаксис строки 22, но я не могу найти что-то не так с ним.
from django.http import HttpResponse
from django.shortcuts import render
import operator
def homepage(request):
return render(request, 'home.html')
def count(request):
fulltext = request.GET['fulltext']
wordlist = fulltext.split()
worddictionary = {}
for word in wordlist:
if word in worddictionary:
#increase
worddictionary[word] += 1
else:
#add to the dictionary
worddictionary[word] = 1
sortedwords = sorted(worddictionary.items(), key=operator.itemgetter(1), reverse=True)
return render (запрос, 'count. html', {'fulltext': fulltext, 'count': len (wordlist), 'worddictionary': worddictionary.items ()})