Hey! Am in a very big trouble. At 1st am sorry for my english. I do many mistakes:-( Sorry. Is here some1 who could help me,pls? The programm should work on a basic of "fields". My homework is to create a programm which would work like this: 1)one put some numbers into the programm - doesnt matter how many numbers eg. 1,2,8,7,4,6,2,1,0,5,4,4,1,1,0,9,8 2)the programm should write: a)how many is single of the numbers b)what number is the most often If u can, pls send me the code into my email pepaklima2@seznam.cz Thank u in advance!
Really, you should do your own homework, but just this once:
stuff={} for num in raw_input('Lay some numbers on me! ').split(): stuff[num] = stuff.get(num,0)+1 pairs = zip( stuff.values(), stuff.keys() ) if pairs: pairs.sort() if pairs[0][0] == 1: print 'Singletons:', for c,n in pairs: if c > 1: break print n, print else: print 'No singletons.' print 'At %d occurrances, %s was most popular.' % pairs[-1] else: print 'Well what the heck do you expect?'
And a little help with your English as a bonus: We have these things called "vowels" that we put into words like "please" to make them sound more sincere. Typing in full words gives people the impression that you are really not so lazy -- then they won't even notice that you are asking them to do your howework for them without even trying to write a single line of code yourself.