[Python] My backslash n command is not breaking my line [closed]

Discussão em 'Python' iniciado por Stack, Abril 21, 2025.

  1. Stack

    Stack Membro Participativo

    This is the code can somebody find the problem?

    todos = []

    while True:
    user_action = input("Type add ,show, complete, edit or exit: ")
    user_action = user_action.strip()

    match user_action:
    case 'add':
    todo = input("Enter a todo: ") + "/n"

    file = open('todos.txt', 'r')
    todos = file.readlines()
    file.close()

    todos.append(todo)

    file = open('todos.txt', 'w')
    file.writelines(todos)
    file.close()
    case 'show':
    for index, item in enumerate(todos):
    row = f"{index+1}-{item}"
    print(row)
    print(len(todos))
    case 'edit':
    number = int(input("Number of the todo to edit: "))
    number = number - 1
    new_todo = input("Enter a new todo: ")
    todos[number] = new_todo
    case 'complete':
    number = int(input("Number of the todo to complete: "))
    todos.pop(number)
    case 'exit':
    break

    print("Bye...")


    I was expecting the \n to break the line but it got printed for some reason.

    There is no error, only the backslash n is getting printed.

    Continue reading...

Compartilhe esta Página