Avatar ·

How to check multiple variable values with an if statement?

📁 Advanced Python Topics, question, example, work, project

Hi! I'm working on a large project. But I'll explain my question using a different example...

Let's say I need to create a program that can only exit itself)

But the user can write the word "exit" in different ways, for example, "EXIT", "VYHOD", "Exit", "exit" or "ds[jl" (in Latin layout) etc.

Then the code would look something like this

vyhod = input('Enter the word "exit" to exit the program:')if vyhod == 'exit':    exit(0)if vyhod == 'Exit':    exit(0)if vyhod ==                     
Avatar ·

Usually, some kind of web framework is used

I recommend starting with

from wsgiref import simple_serverdef app(environ, start_response):    start_response('200 OK', [('Content-type', 'text/plain')])    retu ['Hello world!']server = simple_server.WSGIServer(('', 8000), simple_server.WSGIRequestHandler)server.set_app(app)server.serve_forever()

Here is the simplest code that returns an HTML page. But don't reinvent the wheel. There are a huge number of lightweight frameworks

Log in to leave an answer

Blogs