On 10/7/22 21:32, Axy wrote:
So, seriously, why they needed else if the following pieces produce same result? Does anyone know or remember their motivation?

In real scenarios there would be more logic in the for block that would meet a condition and break out of the loop. If the condition is never met, the else block runs. To steal from w3schools:


fruits = ["apple", "peach", "cherry"]
for x in fruits:
  print(x)
  if x == "banana":
    break
else:
  print("Yes we got no bananas")


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to