I have this piece of code from collections import namedtuple
Device = namedtuple('Device', ['Name', 'Timestamp'])
#add samples
deviceList = [Device(Name = "alo", Timestamp="00000"), Device(Name = "lilo", Timestamp="1111"), Device(Name = "piko", Timestamp="2222")]
def findDeviceByName(listOfDevices, DeviceName):
print(listOfDevices)
for x in listOfDevices:
if (DeviceName == x.Name):
return True
else:
return False
print(findDeviceByName(deviceList, "lilo")) #returnes False even if lilo is in deviceList
print(len(deviceList)) #prints 3
and for some reason this foreach loop stops at first element in the list, but you can clearly see there are 3 elements in the list, even len() says so
not sure why this is happening, if anyone has any idea, let me know Thanks for Anwsering and Best Regards