How to find the mean of a list
<p>I'm very new to python and trying to write some code so that the user enters something. If it's an integer it's sorted into the Numbers list, if it's a string it goes into the String list. </p>

<p>I want to be able to find the mean of all the numbers that are in the list and print out the result.
And in the String section I want to be able to print out everything within the string and its length.
User types 'save' to exit and if input is valid that's caught.</p>

<pre><code>Numbers = []
String = []

while(True):
    user_input = input("What's your input? ")
    if user_input == "save":
        break
    elif user_input.isdigit():
        Numbers.append(user_input)
        for i in range(len(Numbers)):
            Numbers[i] = int(Numbers[i])
            print(sum(Numbers)/len(Numbers)
    elif isinstance(user_input, str):
        String.append(user_input)
        print(String)
        print (len(String)-1)
    else:
        print("Invalid input.")
        break
</code></pre>

<p>There is good thing called <a href="https://docs.python.org/3/library/statistics.html#statistics.mean" rel="nofollow"><code>statistics.mean</code></a>:</p>

<pre><code>from statistics import mean
mean(your_list)
</code></pre>

python list python-3.x