How do I print over some strings that already existed? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

How do I print over some strings that already existed?

For example, I have "Hello World" printed, then the cursor goes back to 'H' and print "Great" so it changes the word into "Great World"

22nd Sep 2018, 2:39 PM
William Tseng
William Tseng - avatar
4 ответов
+ 3
Nguyễn Văn Hoàng Yeah carriage return doesn't work on SoloLearn's console
22nd Sep 2018, 8:27 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 2
William Tseng the carriage return \r can be used to override the current line of the terminal. But I don't think it will work on SoloLearn console.
22nd Sep 2018, 3:44 PM
Hoàng Nguyễn Văn
Hoàng Nguyễn Văn - avatar
+ 1
You can add it into a variable, print the variable, make changes to it and then print again the same variable. You can also use clear screen function to make it appear like if it was changing
22nd Sep 2018, 3:24 PM
Alexander Santos
Alexander Santos - avatar
0
that's the only way to achieve it? Can't we move the cursor around the console?
22nd Sep 2018, 3:40 PM
William Tseng
William Tseng - avatar