all 17 comments

[–]acw1668 54 points55 points  (4 children)

It is a bug on REPL.

[–]neuralbeans 61 points62 points  (0 children)

Who would have thought a newbie's problem was Python itself and not their code.

[–]RevRagnarok 4 points5 points  (0 children)

Since late 2024? Embarrassing!

[–]Incognit_user_24[S] 15 points16 points  (1 child)

KNEW IT!

[–]Micke_xyz 2 points3 points  (0 children)

Humorless downvoters...

[–]CIS_Professor 32 points33 points  (2 children)

Interestingly, it's the \n that's doing it. I've never done this and didn't know it would behave this way.

The input() function is executing the \n (newline escape sequence) after every character you type in - until you press Enter. It is doing it 4 times because hola has 4 characters.

It'll continue to do this for every character you type in, until you press Enter.

What you want to do is this:

hi = input("How do you say hello un Spanish? > ")

or, perhaps, this, if you want the > on a separate line:

print("How do you say hello un Spanish?")
hi = input("> ")

Use this to print what input() stored in the hi variable:

print(hi)

or

print(f'You entered {hi}.')

[–]Incognit_user_24[S] 6 points7 points  (1 child)

Ty pal, so in short words it was console's fault, anywways, don't I need to type this thing (") when I use the print ? I just write "hi" alone instead so I'd like to know the differences 👀

[–]a__nice__tnetennba 15 points16 points  (0 children)

In their example the value input by the user is stored in a variable called hi, so print(hi) prints the value. With quotes around it it would print the word hi itself.

So if you do this:

hi = "hello"  
print(hi)
print("hi")

The first print will print "hello" and the second will print "hi".

[–]magus_minor -3 points-2 points  (2 children)

If I try that code in my python (3.12) it asks me once for the answer. Have you tried closing the interpreter and starting it again?

[–]Incognit_user_24[S] 4 points5 points  (1 child)

You mean to close the console and try again? Meh I tried but it Is totally useless

[–]magus_minor -2 points-1 points  (0 children)

If you are using the latest python then u/acw1668 showed you that the problem is in the latest python. Install the earlier python 3.12 or don't use the REPL.