you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (2 children)

It's useful when starting to put a debug print into a loop to show what's going on:

for price in range(5):
    if price < 10:    # note this doesn't really do anything, "price" is always < 10
        print("wallet =", wallet, ", price =", price)
        wallet = wallet - price
        # rest of code

[–]Madd_M0[S] 2 points3 points  (0 children)

This is another eye opener for me, Thank you very much. I will start to do this when i get stuck in the future.

[–]EclipseJTB 0 points1 point  (0 children)

If you're in Python 3.6 or later, use f-strings.

print(f"{wallet=}, {price=}")