Jun-17-2018, 11:49 AM
(Jun-17-2018, 11:28 AM)tryingtolearnpython Wrote:trials = 10000 successes = 0 for _ in np.arange(trials): rolls = np.random.choice(dice, k) if sum(rolls == 6) > 0: successes = successes + 1 successes / trialsin the code above, what does it mean to use _ after for? for _ in np.arange(trials):
_ is the variable in which the key values are stored. For iterates over the keys in a list. So for every key, there is one loop.
On every single instance of the loop, suppose it is at the starting key value, _ is set to the key it is iterating. So if you use print(_) then you will get the key.
_ is the name of the variable. You can change it to anything you want it's just a placeholder, like: Giraffe;Comet_Man and etc.