this will solve your issue:

answer = raw_input("Vilken?")
if answer.lower().strip() == "1":
    print("Okej! (1)")
elif answer.lower().strip() == "2":
    print("Okej! (2)")
elif answer.lower().strip() == "3":
    print("Okej! (3)")

change input to raw_input

Answer from Night King on Stack Overflow
๐ŸŒ
Python Examples
pythonexamples.org โ€บ python-read-string-from-console
How to Read String from Console as Input in Python?
# Read input string from user ... on the console when program execution is executing input() function. Type the string in the standard output where the prompt appears, and click Enter or Return key. The new line is considered as end of the input, and the execution continues ...
Discussions

How to read a line in the terminal with python - Stack Overflow
This has been discussed in the ... in Python ยท However, if you want to have something which provides you both a means of printing to the terminal and giving you the lines, then you will need to implement your own type which inherits from io.TextIOBase or uses io.TextIOWrapper. ... Sign up to request clarification or add additional context in comments. ... No, that would read user input, ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to read a line from python currently in console? - Stack Overflow
I want to use a line of code that can read what I was typing in console, for use with asyncio module in python. My code prints data when it receives it from the server, and after it does that, I wa... More on stackoverflow.com
๐ŸŒ stackoverflow.com
August 12, 2016
python - User input and command line arguments - Stack Overflow
Careful not to use the input function, unless you know what you're doing. Unlike raw_input, input will accept any python expression, so it's kinda like eval ... Use 'raw_input' for input from a console/terminal. if you just want a command line argument like a file name or something e.g. More on stackoverflow.com
๐ŸŒ stackoverflow.com
Reading a line from standard input in Python - Stack Overflow
It also strips the trailing newline character from the string it returns, and supports history features if the readline module is loaded. readline() takes an optional size argument, does not strip the trailing newline character and does not support history whatsoever. Since they don't do the same thing, they're not really interchangeable. I personally prefer using raw_input() to fetch user input, and readline() to read lines ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Recenturesoft
recenturesoft.com โ€บ taking-input-from-console-in-python
Taking input from console in Python
The raw_input() function takes a string as an argument and prints it to the console ยท If you want to take input from the console in a more interactive way, you can use the input() function. This function takes a string as an argument and prints it to the console.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ read-a-file-line-by-line-in-python
Read a File Line-by-Line in Python
January 5, 2023 - This code snippet opens a file object whose reference is stored in fp, then reads in a line one at a time by calling readline() on that file object iteratively in a while loop. It then simply prints the line to the console.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 38831703 โ€บ how-to-read-a-line-from-python-currently-in-console
How to read a line from python currently in console? - Stack Overflow
August 12, 2016 - . .") def empty_stdin(): output = "" while True: temp = sys.stdin.buffer.read(1) if temp == "": break else: output += temp return output if DBG: loop.set_debug(DBG) async def write(): loop = asyncio.get_event_loop() while True: line = await loop.run_in_executor(None, sys.stdin.readline) line = prev_stdin + line prev_stdin = "" for i in transports: loop.call_soon(i.write,line.encode('utf-8')) class Server(asyncio.Protocol): def connection_made(self,transport): self.transport = transport transport.write(b"Connected") def data_received(self, data): print("\n%s"๏ฟฝta.decode('utf-8')) prev_stdin =
๐ŸŒ
Wikiversity
en.wikiversity.org โ€บ wiki โ€บ Python_Concepts โ€บ Console_Input
Python Concepts/Console Input - Wikiversity
In the context of this lesson, the word "console" implies the visual display which you see in front of you when you sit at your desk, and also the attached keyboard. The keyboard provides "console input" while the visual display provides console output ยท Other input devices such as mice, ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ taking-input-from-console-in-python
Taking input from console in Python - GeeksforGeeks
January 12, 2026 - You are free to write the next command on the shell only when these prompts have appeared after executing the first command. The Python Console accepts commands in Python that you write after the prompt. Accepting Input from Console User enters the values in the Console and that value is then used in the program as it was required.
Find elsewhere
๐ŸŒ
Python Module of the Week
pymotw.com โ€บ 2 โ€บ readline
readline โ€“ Interface to the GNU readline library - Python Module of the Week
If it is not the first word, then the first word is used to find candidates from the options dictionary. There are three top-level commands, two of which have subcommands: ... Following the same sequence of actions as before, pressing TAB twice gives us the three top-level commands: $ python readline_buffer.py Prompt ("stop" to quit): list print stop Prompt ("stop" to quit):
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-read-a-file-line-by-line-in-python
How to Read a File Line by Line in Python
December 14, 2022 - Hopefully, this article helped you understand how to read a file line by line in Python using the read(), readline(), and readlines() methods and a for loop.
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ readline.html
readline โ€” GNU readline interface
The readline module defines a number of functions to facilitate completion and reading/writing of history files from the Python interpreter. This module can be used directly, or via the rlcompleter module, which supports completion of Python ...
๐ŸŒ
Wiingy
wiingy.com โ€บ home โ€บ learn โ€บ python โ€บ input from console in python
Input from Console in Python - Wiingy
April 15, 2025 - The readlines() method is used to read the contents of the file and store them as a list of strings in the variable โ€œlinesโ€. Finally, we loop through the lines and print each line after removing any whitespace using the strip() method.
๐ŸŒ
Linux Hint
linuxhint.com โ€บ python-readlines
Python readlines()
May 26, 2023 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
๐ŸŒ
Guru99
guru99.com โ€บ home โ€บ python โ€บ python readline() method with examples
Python readline() Method with Examples
August 13, 2025 - To do that, first, open the file in read mode using open() function. The file handler returned from open(), use it inside while โ€“loop to read the lines. Python readline() function is used inside while-loop to read the lines.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 39495407 โ€บ python-how-to-choose-line-in-console-to-read-from
input - Python - How to choose line in console to read from - Stack Overflow
I am not sure in what case this would be required but anyway, the input captures a whole line, meaning pressing "enter" ends the reading. skipping a line is thus impossible, not multi-line input. However, you can do so when reading from a file but then again I see no reason to need this functionality
๐ŸŒ
Finxter
blog.finxter.com โ€บ 5-best-ways-to-read-input-from-the-console-in-python
5 Best Ways to Read Input from the Console in Python โ€“ Be on the Right Side of Change
March 3, 2024 - The sys.stdin object can be used to read input directly from the console, especially useful for interacting with input streams or handling larger or multi-line text. ... import sys print("Enter a message, then press Ctrl+D (Unix) or Ctrl+Z (Windows) to submit:") message = sys.stdin.read() ...
๐ŸŒ
Reddit
reddit.com โ€บ r/pihole โ€บ reading console output line-by-line in python
r/pihole on Reddit: Reading Console Output line-by-line in python
February 17, 2021 -

Hi, I've just gotten pihole 5.2.4 running on my raspberry pi 0 w. (First raspberry pi project I've done, pretty happy!) But I'm not quite done yet, I have something in mind I'd like to do with it. I'd like to filter out the live output from the pihole -t command to only include datapoints that include a certain IP address, or DNS that's been blocked. Could this be done in python?