How do I find the max of inputed numbers? Here's what I have so far. It's giving me an error message: '"int" object is not iterable'

```
def greatest(num):
for index in range(10):
num=input('Enter the number of units sold')
print max(num)
```

You can either put them all into a list and then run `max()`

on the *list,* or (if you don't need the list for anything else) simply maintain your own maximum with something like:

```
def greatest(num): # why num here??
maxnum = -1
for index in range(10):
num = input ('Enter the number of units sold')
if num > maxnum:
maxnum = num
print maxnum
```

You need to accumulate the numbers in a list or some other iterable data structure:

```
def greatest():
data = [input('Enter the number of units sold') for _ in range(10)]
print max(data)
```

The error message is because `max`

gives you the largest number in a series of numbers, while `input`

returns an int.

What you're probably trying to do is this:

```
def greatest(num):
numbers = []
for index in range(10):
numbers.append(input('Enter the number of units sold'))
print max(numbers)
```

You need to hold those numbers that you are getting from the user in a data structure, then find the maximum after you have finished collecting. Right now you are just overriding the value of `num`

in each iteration which doesn't help at all since you can't examine the previous input numbers. This is why you are getting an error from `max`

, expecting something to iterate over. Going with what you have so far something like this would work,

```
def greatest():
l = []
for index in range(10):
l.append(input('Enter the number of units sold'))
return max(l)
```

But this would be even better:

```
def greatest():
return max(input('Enter the number of units sold') for _ in xrange(10))
```

Similar Questions

For example my input numbers are: 10 10 and 15. The second input will be ignored since it is already duplicated. So the sum would be 10+15 - 25. How do I do this? public class MP2A { public static Sca

I want just numbers. string str_a = a1bc2d23ghj2; int in_b = convert.toint32(str_a); // doesn't works I want the output of in_b to be: 12232

How do I convert all varchar(max) columns to text type? I know varchar(max) is recommended but I still want to use type text because CakePHP doesn't automagically convert varchar(max) to textarea (HTM

I've got a mysql table where each row has its own sequence number in a sequence column. However, when a row gets deleted, it leaves a gap. So... 1 2 3 4 ...becomes... 1 2 4 Is there a neat way t

How to create in Android Java a random number between min and max excluding some numbers that fall between min and max.? I have three vars, each is a random number between 1-100. I was able to do the

Working with databases, how can I find MAX using relational algebra?

I am trying to find a way to get the max value of an array, then find all indexes of that value. I want to repeat this two more times. I have an array of 8 scores. I want to find all first places, all

https://dl.dropboxusercontent.com/u/1422002/excel.PNG I would like to find the max value in column C and return the associated AM unit (A3,A16,A29) in E5. Then, I would like to find the next highest

If a user inputs [3, 5, 2] How would I write a code so that it would correlate 3 to a, 5 to b, and 2 to c? public static void main(String[] args) { int a = input.nextInt(); int b = input.nextInt

Basically what I want to do is print u'\u1001', but I do not want the 1001 hardcoded. Is there a way I can use a variable or string for this? Also, it would be nice if I could retrieve this code again

If I have a range of numbers from 0 - 70, I want to pick five random numbers and the sum of random numbers to be higher then 140 and lower then 220. I want to do that until the sum of five random numb

I am trying to query for a maximium value from 5am to 5am the next morning. I would also like to have the start of query date in the results. here is what I have so far Select Max(Value) as RWQ22003

I am trying to subtract numbers from a list that the user enters. For example, I have this for addition which works the way I want it to: print(\nAddition) n = int(input('How many numbers are you ad

How can I find the maximal integer value of an unknown type? Is there something more efficient than this: template<class T> T test(T i) { if (((T)-1) > 0) return -1; T max_neg = ~(1 <<

Funny one this, I've got a table, addresses, with a list of address details, some with missing fields. I want to identify these rows, and replace them with the previous address row, however these mu

I would like to know exactly what is going on with omp parallel for and other similiar constructs. How do I find how these are implemented? A short summary of someone who knows about this would be gre

I want to find all the consecutive numbers in a an ordered int[8] of casual numbers from 0 to 31. The consecutive numbers must be from minimum length of 3 and a max of 5 numbers. In the example the la

Is there a good way to reverse UISlider values? The default is min on the left and max on the right. I'd like it to work the opposite way. Rotating it 180 degrees seems a bit silly. Any ideas? Thanks!

For all text nodes, how do I find the parent element's class and tag type

I am constructing a line graph in PHP. I was setting the max value of the line graph to the max value of my collection of items, but this ended up making the graph less readable you are unable to view

I was asked to write a program to open a txt.doc and find the: number of numbers in the list, the sum and the avg. With I compile the code my valves equal zero. I cant find out where I went wrong. #i

I have a very simple JS check and i am looking for a list of dummy cc numbers which i can exclude. Just for mastercard AmEx and Visa var dummyCCArr = new Array(); dummyCCArr=[5105105105105100,41111

I can find quite a few permutations of this question, but not this (rather simple) one: how do I find the maximum value of a specific column of a numpy array (in the most pythonic way)? a = array([[10

computerTotal = (int) Math.ceil(Math.random() * 21); Can someone show me how to get 16 - 21 random number I keep getting errors when i try to implement the Math.floor function... As you can see i'm n

Hi I'm working on an assignment and got stuck on this part, how do I validate decimal numbers/numbers in shell? It can accept numbers but not decimal numbers. I want it to be able to accept both. This

I know this is a classic interview question, but here is my quick attempt at creating a function which returns the lowest common multiple of two numbers, something I never have to do in my day job: de

How to find the value in the max attribute of input element using Jquery <input type=number id=pageNumber class=toolbarField pageNumber value=1 size=4 min=1 tabindex=7 max=29> I

I am refering to the example here. How do I get the max id?

I've set suhosin.perdir = 'p' in my ini file. I would now like to change suhosin ini settings on a per-folder basis. The following all work (running phpinfo() inside the desired folder shows the chang

I'll have a list of numbers, each on its own line (say 0 -100). How do I find the numbers that are not listed or missing?

I have a string list having characters with numbers. I just wanted to split the string to get the number and later I need to find the max number from that splitted number list. Match String abc Examp

I have written a program in python 3.3 and I am using WinPython and Inno to make a portable python installation. However, there are a lot of modules in the WinPython installation that I do not really

I develop app by using Lua Glider 2 + Corona SDK latest release. How can I find which version of Lua do it use? Thank you.

I was asked this question by a friend. You are given a table with just one field which is an integer. Can you the highest value in the field without using the MAX function ? I think we can change the

def adding(): total = 0 x = 0 while x != 'done': x = int(raw_input('Number to be added: ')) total = x + total if x == 'done': break print total I cant figure out how to add numbers that a user is inp

How do I find out which version of Java I am using Perl programming and using that execute some jar file based on that?

How do I generate random numbers in a microcontroller efficiently? Are there any general guidelines or a particular fast method?

I need to run an equipment audit and to do that I need to obtain the Windows PC, monitor etc. serial numbers. So I faced with going to each PC and manually writing down the numbers. Is there a way I c

Wikipedia says: Selection algorithms: Finding the min, max, both the min and max, median, or even the k-th largest element can be done in linear time using heaps. All it says is that it can be done

I received help from someone here a week or so ago, but there seems to still be a problem with my code. I am running Android 2.0 so I cannot use the methods to get the UI, instead I need to call the m

I'm trying to keep a div element a specific ratio (say, 1:2), but keep the width less than 200px. What I've got so far: div { width: 100%; height: 0; padding-bottom: 50%; max-width: 200px; } It doesn

I want to sort a String that has nr. How do I do that? Lets say my integers are Class2 3 4 1 in main I do class2.Sort(); Thanks in Advance.

I have a python / django app on heroku. how do i find the postgres version running on my app?

I'd like to calculate a logarithmic range of numbers from 1 to MAX, with the approximate total count of numbers being TOTAL. A non-logarithmic example might be: $max = 3600; $total = 100; $range = ar

I have a windows forms app with a textbox control that I want to only accept integer values. In the past I've done this kind of validation by overloading the KeyPress event and just removing character

How do I find out who the author of a revision is in SVN?

I am writing a program that must print numbers at first which was entered at last. So here is my code: #include <iostream> using namespace std; void recursive() { long long n; if((cin>>n)&

web,search,web2.0,1,seo,networking,social web,search,web2.0,3,seo,networking,social web,search,web2.0,4,seo,networking,social How do I remove 1, 3 and 4 from above lines??

The O(K * logK) algorithm for finding the largest K numbers in a max heap of size N is well known. I heard about that there is an O(K) algorithm for solving this problem. I do not find the literature

I have a table with a column of dates which includes dates and NULL values. I am trying to figure out a way to find the MAX date, per ID, or if there is a NULL value, then to return NULL instead. So f