Results 1 to 5 of 5

Thread: Python - Function that averages user input numbers.

  1. #1
    Join Date
    Mar 2014
    Beans
    14

    Python - Function that averages user input numbers.

    Hello good people,

    I am working on a function that prompts a user for a numerical character and ends when a non-numerical character is inputted.

    In my code, I managed to get it to prompt for a number, but afterwards it does not work.

    Here is a pastebin of my code:
    HTML Code:
    http://pastebin.com/SVrRmugs
    Many thanks in advance for any help.

    Edit: Solved. Many thanks for the input everyone!
    Last edited by Yozuru; April 6th, 2014 at 05:25 PM.

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,330
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Python - Function that averages user input numbers.

    how can you calculate anything from L if you don't save anything in it?
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #3
    Join Date
    Apr 2005
    Location
    EU - UK
    Beans
    3,318
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Python - Function that averages user input numbers.

    Put your call to input inside the while loop and as Yozuru already said, don't forget to save the values you are getting from the user in L.

  4. #4
    Join Date
    Mar 2014
    Beans
    8

    value != ascii character

    You have:
    Code:
    List = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    Try this:
    Code:
    List = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
    A value like 0 is not the self like ascii character "0"

    value 0 is in binary 0000h
    character "0" is in binary 0030h



    Tell me, when it works!

  5. #5
    Join Date
    Mar 2014
    Beans
    14

    Re: value != ascii character

    Ahh that makes a lot of sense! Many thanks for your help. (:

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •