# Import Packages
import random
# Global Variables
perf_num = 500
species = [20]
temp_num = 0
length = 0
s = 0
# Main Program
for num in range(100):
r1 = int(random.random()*10)
r2 = int(random.random()*10)
species.append(r1)
length = len(species)
while s < length:
print(s)
if species[s-1] > species[s]:
temp_num = species[s-1] - r1
species[s-1] = temp_num
else:
temp_num = species[s] - r1
species[s] = temp_num
if s-1 < 5:
species[s-1] = []
s += 1
print(species)
Please don't explain in very complicated coding language as I just started learning Python from youtube. I tried making my own program and continue to get this error.
In the following line:
species[s-1] = []
you're assigning an empty list to a list of numbers, which results in something like:
20 [20, 2] 2
Then when you try to compare a number and a list:
if species[s-1] > species[s]:
you'll get that error:
TypeError: unorderable types: int() > list()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With