Find answers, ask questions, and connect with our <br>community around the world.

Home Forums Scientific computing with Python Scientific Computing with Python : Lesson 11

Tagged: 

  • Scientific Computing with Python : Lesson 11

    Posted by Rohan on February 25, 2024 at 8:27 am

    Hello Everyone,

    I was trying to write the code for lesson 11 of Scientific Computing with Python.

    The program asks user to input numbers and then stores it in a list numbers. It will then add all the numbers entered in the list as soon as a 0 is entered by the user.

    But I am getting the following error.

    Can someone please help me resolve this error.

    Rohan replied 1 month, 3 weeks ago 2 Members · 2 Replies
  • 2 Replies
  • Rahul

    Member
    February 26, 2024 at 9:57 am

    Hi Rohan,

    Have you used ‘input’ as the variable name anywhere in the same notebook and executed it prior to this?
    Other than that, I am able to run the same commands. Could you also try to use the prompt as string within the input function and see if the issue is with the input function or using the prompt? You can use
    num = int(input(“Enter the number:”))

    Best regards
    Rahul
    Flowthermolab support

  • Rohan

    Member
    February 26, 2024 at 10:12 am

    Hello Rahul,

    Thank you for your reply. I hadn’t used input as a variable name as such but I had used it elsewhere just to take user values. I guess the issue was with the prompt command.

    The code is working fine when I used the promt as string to the input function and then converting it to an integer to do the addition.

    Thank you.

Log in to reply.

error: Content is protected !!