I've added a print statement which should clarify what you are actually doing.

p = [1, 2, 0, -1, 3, 4, 5]
smaller = 0
bigger = 0
i = 0
while i < len(p):
print "comparing", p[1], p
if p[i] >= p:
bigger += 1
print bigger
i += 1

I think you want two for loops. Note that the logic is different if the list is sorted first.

stop = len(p)
for x in range(0, stop):
greater_list = []
for y in range(0, stop):
if p[x] < p[y]:
greater_list.append(p[y])
print p[x], "greater =", greater_list

I've added a print statement which should clarify what you are actually doing.

p = [1, 2, 0, -1, 3, 4, 5]
smaller = 0
bigger = 0
i = 0
while i < len(p):
print "comparing", p[1], p
if p[i] >= p:
bigger += 1
print bigger
i += 1

I think you want two for loops. Note that the logic is different if the list is sorted first.

stop = len(p)
for x in range(0, stop):
greater_list = []
for y in range(0, stop):
if p[x] < p[y]:
greater_list.append(p[y])
print p[x], "greater =", greater_list

Thanks I'm tryng to this.

# -*- coding: utf-8 -*-
p = [1, 2, 10, -1, 3, 4, 5, 9, +66, 99, 88]
min_greater = 0
min_smaller = 0
stop = len(p)
for x in range(0, stop):
greater_list = []
smaller_list = []
for y in range(0, stop):
if p[x] < p[y]:
greater_list.append(p[y])
elif p[x] > p[y]:
smaller_list.append(p[y])
if len(greater_list) > min_greater:
min_greater = len(greater_list)
a = x
b = p[x]
c = greater_list
if len(smaller_list) > min_smaller:
min_smaller = len(smaller_list)
Amin = x
Bmin = p[x]
Cmin = smaller_list
if len(smaller_list) == len(greater_list):
print "Average element is:", p[x]
print ''
print "Minimum number:", b, "\nElement index:", a, "\n", "Len greater elements:", min_greater
print "Greater than", b, "is", c
print ''
print "Maximum number:", Bmin, "\nElement index:", Amin, "\n", "Len greater elements:", min_smaller
print "Smaller than", Bmin, "is", Cmin
print ''
#alist = [ '1', '1', '2', '1', '3', '4', '1', '3']
#print [(a, alist.count(a)) for a in set(alist)]

Hey tonyjv, how to use your code? Is not working!

I'm using Python 2.6.4 and Linux.

And this code works so:

File "P.py", line 3
print [y in x if y>limit]
^
SyntaxError: invalid syntax

Sorry typed it without testing from mobile 'y for' missing:

x = [1, 2, 10, -1, 3, 4, 5, 9, +66, 99, 88]
for limit in (-1,1,3):
print 'Limit',limit
data = [y for y in x if y>limit]
print "Data: %s, Len: %i, Sum: %.2f" % (data, len(data), sum(data))

Dear Friends,
I developed Desktop application in C# .Net for client. client purchased software and installed it one than more system without my permission. How to restict him to not ...