# for i in [...]
for i in [0, 1, 2, 3]: # this list is by item, and can be any datatype (i.e. strs are ok)
# {do...}
# can also use range[int], which evenly distributes across the range.
# While not needed, np.arrange(from, to, increment size) allows for incrementing floats.
for i in range(3): # this will go 0-3, though two int arguments will start/stop at those values
# {do...}
# while loops with an 'i'
i = 0
while i < 10:
# {do...}
while True: # loops infinitely, requiring a break condition
best_game = input("What is the best strategy game? ")
if "starcraft" in best_game.lower():
print("correct! ^_^")
break # only stops prompting if starcraft is in answer.
text= "IPSO FACT?"
for c in text:
c_lower += c.lower() # += automatically concatenates strings.
print(c_lower)
# more efficiently, you can use str.join
[c,lower() for c in text] # this is a list comprehension
# OR
(c,lower() for c in text) # this is a generator expression
Acemoglu, Daron, and Simon Johnson. 2023. Power and Progress: Our
Thousand-Year Struggle over Technology and Prosperity. London:
Basic Books.
Bicchieri, Cristina. 2006. The Grammar of Society: The Nature and
Dynamics of Social Norms. New York, NY: Cambridge University Press.
———. 2016. Norms in the Wild: How to
Diagnose, Measure, and Change Social
Norms. Oxford University Press.