Average program python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Average program python?

I'm trying to create a program that takes numbers as input in the range that comes also from input and outputs the average but I have problems with the for loop. Some advice?

6th Dec 2016, 5:18 PM
Nicoletta Alba
Nicoletta Alba - avatar
2 Answers
+ 1
when you create a range you are working with it like you would with a list. for does something as for every value in your list, tuple, range, ... for value in range(3): print(value) is the same as... x = range(3) print(x[0]) print(x[1]) print(x[2])
8th Dec 2016, 11:19 PM
Leon N.
Leon N. - avatar
0
Wrote a script with a couple of possible answers here: https://code.sololearn.com/cdeXj3pXFnxv/#py Please upvote if it's helpful!
9th Apr 2017, 5:40 PM
Avery Abbott
Avery Abbott - avatar