vaibhavsingh97 / random-word

This is a simple python package to generate random english words
https://pypi.org/project/random-word/
MIT License
123 stars 25 forks source link

Error when trying to obtain a random word #36

Closed RapidCompiler closed 4 years ago

RapidCompiler commented 4 years ago

Description

Code

from django.shortcuts import render
from random_word import RandomWords

def hangman(request):
    return render(request,'hangman/plain_page_2.html')

def hangman_org(request):    
    r = RandomWords()
    guess = request.POST.get('guess')
    w_len = request.POST.get('w_len')
    lst = []
    word = r.get_random_word(hasDictionaryDef="true",minLength=w_len,maxLength=w_len)
    count=0
    word = word.lower()
    length = len(word)
    for i in range(1,length+1):
        lst.append(i)
    context = {
        'guess' : guess,
        'lst' : lst,
        'hmword' : word
        }
    return render(request,'hangman/plain_page.html',context)

Expected behavior A Random Word must be generated without encountering the above mentioned error.

Environment (please complete the following information):

RapidCompiler commented 4 years ago

I even tried generating a random word outside the Django application. The same error was encountered.