713 if bytes < unit:
714 return f"{base * bytes / unit:.1f} {prefix}"
715
716 return f"{base * bytes / unit:.1f} {prefix}" 717
718
719def do_pprint(value: t.Any) -> str:
713 if bytes < unit:
714 return f"{base * bytes / unit:.1f} {prefix}"
715
716 return f"{base * bytes / unit:.1f} {prefix}" 717
718
719def do_pprint(value: t.Any) -> str:
Using a loop variable (i.e. defined by a for loop or a list comprehension or a generator expression) outside the loop can create subtle bugs, like the variable not being defined if the list was empty. Generally, you should avoid using loop variables outside the loop, or define them early.
for i in items:
if item_name(i) == "coffee":
price = calculate_cost(i)
print(price) # raises `NameError` if `items` is empty
price = None # Define variable outside loop
for i in items:
if item_name(i) == "coffee":
price = calculate_cost(i)
print(price)