I'm searching to make a loop to go throw samples till I reach the result. Example:

```    i=(list(np.random.randint(2, size=5)),list(np.random.randint(2,  size=2)),list(np.random.randint(2, size=7)),list(np.random.randint(2, size=7)),list(np.random.randint(2, size=9)),list(np.random.randint(2, size=8)),list(np.random.randint(2, size=7)))

tot=0
for j in range(0,len(anytable)):
if resp(i,(anytable.iloc[j,0:7].tolist())):  #this function "resp"  gives me True and False and add 1 to variable "tot"
tot=tot+1```

Now I want to stop till I have to tot>=100 . So I have to generate many "i" samples lists till I get to tot>=100.

How can I do this?

Thank you very much

Sep 20, 2018 in Python 318 views

## 1 answer to this question.

I would say, this could be your solution.

```j, tot = 1, 1
while j<len(anytable) and tot<100 :
tot += int( resp(i,(anytable.iloc[j,0:7].tolist())) )
j   += 1```

The condition is false if one of the inequations is false. The incementing operator += on tot is adding the integer representation of a boolean True = 1 or False = 0 to the value of tot.

• 58,090 points

## Error while printing hello world in python.

You must be trying this command in ...READ MORE

## Do-while loop in Python

A more pythonic way would be this: ``` while ...READ MORE

## how do i change string to a list?

suppose you have a string with a ...READ MORE

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE