[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Am I unreasonable in expecting this code to exit when required? # Add up the powers of 2 starting with 2**0 until 2 million is met. n = 1 target = 2000000 sum = 0 while True: x = 2 ** (n - 1) sum += x print(n, sum) if sum >= target: print("Target met.") exit n += 1 print("\n", n, "terms are required.")

- Prev by Date:
**creating a csv from information I have printed to screen** - Next by Date:
**exiting a while loop** - Previous by thread:
**PyCharm, how to setup self contained subprojects** - Next by thread:
**exiting a while loop** - Index(es):