D
D
Daniel2021-10-28 17:37:26
Python
Daniel, 2021-10-28 17:37:26

How to implement multiline input in Python?

I make my task manager, I implemented multiline input in this way:

while True:
    try:
        self.task = input('')
        self.join_task.append(self.task)

    except KeyboardInterrupt:
        break


How to make multiline input so that I can edit a previously written line. In my example, I'll hit enter and I won't be able to edit the submitted string anymore. Are there any libraries or ideas how to make input like in nano editor (linux).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alan Gibizov, 2021-10-28
@datamainer

It seems to me that it is not difficult to take the entered string into a temporary variable, display it on the screen, and request re-entry. If an empty string is entered, the last option is accepted, if not empty - it is put into a temporary variable, onto the screen - and all over again.
Well, after three weeks of learning python, it shouldn't be hard.

V
Vindicar, 2021-10-28
@Vindicar

Under Linux you can use the curses module, but it is not available under Windows.
There you can try using a third-party console module .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question