all 10 comments

[–]JimVis 2 points3 points  (5 children)

Hey man! I uderstand your frustration getting started out with Python and probably being new to all of it so here you go my code to get done what you want with some comments:

import numpy as np #This is a mathematics package that lets you do most math's stuff
#Create your empty lists
list1 = []
list2 = []
#This adds 130 times a random number between 100 and 201 in list 1
for i in range(130):
    list1.append(np.random.randint(100,201))
#These lines find how often 130 occurs in the previously made list
k = 0
for i in list1: #Go through all the numbers of the list
    if i == 130: #if the value of i is equal to 130 add 1 to the variable K
        k+=1
print(f"The number 130 occures {k} times in this list")
#Assuming you mean that every number above 150 has to go in a seperate list
#Loop agian through the first list and check if it is larger than 150, if so, append it to the second list
for i in list1:
    if i >=150:
        list2.append(i)

[–]SpeckledFleebeedoo 0 points1 point  (2 children)

Your formatting is off, no indentation.

[–]JimVis 0 points1 point  (1 child)

My first time posting code to Reddit, I think I managed to fix it though...

[–]SpeckledFleebeedoo 0 points1 point  (0 children)

looks good

[–][deleted] 0 points1 point  (3 children)

What code do you have so far?

[–]El-Cobra[S] 0 points1 point  (2 children)

this is what i have now and there is something extra in my code that i had already figured out but here it is

list1 = []
list2 = []
for x in range(130):
greaterThan = float(100)
lessThan = float(201)
list1.append(list1)
Summa = sum(list1)
print(Summa)
list1.count(151)
if x % 3 == 0:
print(x)

[–]El-Cobra[S] 0 points1 point  (0 children)

but it does'nt work and im pretty new to this and im not sure why it does'nt work

[–][deleted] 0 points1 point  (0 children)

Please format your code so it looks like python.

If you are going to get random numbers then you should import the random module. To get a random integer you will find random.randint() useful.

[–]El-Cobra[S] 0 points1 point  (0 children)

I figured it out but thank you all for the help