TypeError: translator () missing 1 required positional argument: 'word'


esoty doing a practice of python but I have run into a problem when running the code

import json
from difflib import get_close_matches
from flask import Flask, render_template
from flask_bootstrap import Bootstrap

app = Flask(__name__)

collection = json.load(open("collection.json"))

def home():
    return render_template('home.html')

def prueba():
    return render_template('nosotros.html')

def traductor(word):
    if word in collection:
    return collection[word]
elif len(get_close_matches(word, collection.keys())) > 0:
    yn = input("Quizas estas buscando esta palabra %s ? Presiona S 
para si o N para No:b" % get_close_matches(word, collection.keys())[0])
    if yn == "S":
        return collection[get_close_matches(word, collection.keys())[0]]
    elif yn == "N":
        return "Palabra no encontrada. Por favor busca de nuevo."
        return "No has escrito ninguna palabra"

print('\n***** Bienvenido al Diccionario KUNA *****\n')
word = input("Escribe tu palabra:  ")
output = traductor(word)
if type(output) == list:
    for item in output:
return render_template('traductor.html')

if __name__ == '__main__':

If you could indicate me if it is an argument failure or how the request is built

Here are the logs:

File "/home/jahirocoba/.local/lib/python3.7/site-packages/flask/app.py", line 2309, in __call__ return self.wsgi_app(environ, start_response)
File "/home/jahirocoba/.local/lib/python3.7/site-packages/flask/app.py", line 2295, in wsgi_app response = self.handle_exception(e) 
File "/home/jahirocoba/.local/lib/python3.7/site-packages/flask/app.py", line 1741, in handle_exception reraise(exc_type, exc_value, tb) 
File "/home/jahirocoba/.local/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise raise value 
File "/home/jahirocoba/.local/lib/python3.7/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() 
File "/home/jahirocoba/.local/lib/python3.7/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e)
File "/home/jahirocoba/.local/lib/python3.7/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb)
File "/home/jahirocoba/.local/lib/python3.7/site-packages/flask/_compat.py", line 35, in reraise raise value 
File "/home/jahirocoba/.local/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() 
File "/home/jahirocoba/.local/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) TypeError:
traductor() missing 1 required positional argument: 'word'
asked by user10736987 17.12.2018 в 23:23

0 answers