Ex50 Attribute error

Hi, I was going perfectly in ex50 UNTIL when I have finished my index.html and app.py, an attribute error popped up in PowerShell. Even though I have looked through lots of different forums, I can’t seem to solve the issue.

the error:

Traceback (most recent call last):
  File "C:\Users\MengShiun\.venvs\lpthw\lib\site-packages\flask\app.py", line 2091, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Users\MengShiun\.venvs\lpthw\lib\site-packages\flask\app.py", line 2076, in wsgi_app
    response = self.handle_exception(e)
  File "C:\Users\MengShiun\.venvs\lpthw\lib\site-packages\flask\app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\MengShiun\.venvs\lpthw\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\MengShiun\.venvs\lpthw\lib\site-packages\flask\app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\MengShiun\.venvs\lpthw\lib\site-packages\flask\app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "C:\pyExercise\projects\gothonweb\app.py", line 9, in index
    return render_template("index.html", greeting=greeting)
  File "C:\Users\MengShiun\.venvs\lpthw\lib\site-packages\flask\templating.py", line 148, in render_template
    ctx.app.jinja_env.get_or_select_template(template_name_or_list),
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\environment.py", line 1068, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\environment.py", line 997, in get_template
    return self._load_template(name, globals)
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\environment.py", line 958, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\loaders.py", line 137, in load
    code = environment.compile(source, name, filename)
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\environment.py", line 749, in compile
    source = self._parse(source, name, filename)
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\environment.py", line 606, in _parse
    return Parser(self, source, name, filename).parse()
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\parser.py", line 1038, in parse
    result = nodes.Template(self.subparse(), lineno=1)
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\parser.py", line 1021, in subparse
    rv = self.parse_statement()
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\parser.py", line 175, in parse_statement
    return f()  # type: ignore
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\parser.py", line 255, in parse_if
    node = result = nodes.If(lineno=self.stream.expect("name:if").lineno)
  File "c:\users\mengshiun\appdata\local\programs\python\python36-32\lib\site-packages\jinja2\lexer.py", line 405, in expect
    if not self.current.test(expr):
AttributeError: 'Token' object has no attribute 'test'

app.py:

from flask import Flask
from flask import render_template

app = Flask(__name__)

@app.route('/')
def index():
    greeting = "Hello World"
    return render_template("index.html", greeting=greeting)

if __name__ == "__main__":
    app.run(debug=False)   

index.html:

<html>
    <head> 
        <title>Gothons Of The Planet Percal #25</title>
    </head>
<body>

{% if greeting %}
    I just wanted to say
    <em style="color: green; font-size: 2em;">{{ greeting }}</em>.
{% else %}
    <em>Hello</em>, world!
{% endif %}

    
</body>
</html>

Plz help.

Well, never mind. I solved the issue by updating the python 3 version to the latest one.

A free service run by Zed A. Shaw for learncodethehardway.org.