Check if next value is equal o current value in python loop? - Stack Overflow

PHOTO EMBED

Tue Mar 29 2022 12:44:58 GMT+0000 (Coordinated Universal Time)

Saved by @jacopo #python

last_value = None
for obj in collection:
    if obj.name == last_value:
        # do something
    else:
        # do something different
    last_value = obj.name
content_copyCOPY

https://stackoverflow.com/questions/28258278/check-if-next-value-is-equal-o-current-value-in-python-loop