0

how to prevent newline while taking input ?

while True : x=input("calcii : ") print(eval(x)) I need output like this : Calcii : 2+2 = 4 # 2+2 is input given by user real code : 👇👇 https://code.sololearn.com/cDgTNkPG4AY2/?ref=app

9th Jun 2021, 3:12 PM
Ratnapal Shende
Ratnapal Shende - avatar
6 Antworten
9th Jun 2021, 3:29 PM
Slick
Slick - avatar
9th Jun 2021, 4:32 PM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 2
Slick Thanks for your answer! 😊 what is mean '\033[F' ? is it same as '\r' ? from where I can learn codes like this ?
9th Jun 2021, 4:49 PM
Ratnapal Shende
Ratnapal Shende - avatar
+ 1
Its a character that brings the cursor up to the beggining of the previous line. i think '\r' is for carridge return. Think about a type writer when you get to the end of a line on a piece of paper. When you get to the end, you shove the carridge right back to the begginning of the line. "\033[F" will not go to the beggining of the current line, but the beggining of the previous one thats right above it. i found it by searching "print on previous line python"
9th Jun 2021, 7:15 PM
Slick
Slick - avatar
+ 1
My bad, the character should be "\033[A" not "\033[F" was doing some testing. "\033[A" works just fine
10th Jun 2021, 8:18 AM
Slick
Slick - avatar
0
Slick your code works same without using '\033[F' then what's the case here ? 🤔
10th Jun 2021, 8:07 AM
Ratnapal Shende
Ratnapal Shende - avatar