Python Sprawdź ciąg nie istnieje w tablicy
arr_test = ["thetung1","thetung2","thetung3"]
title = "thetung"
if title not in arr_test:
arr_test.append(title)
Spotless Swan
arr_test = ["thetung1","thetung2","thetung3"]
title = "thetung"
if title not in arr_test:
arr_test.append(title)
# To check if a certain element is contained in a list use 'in'
bikes = ['trek', 'redline', 'giant']
'trek' in bikes
# Output:
# True
listA = [item1, item2, item3]
if item4 in listA:
print('yes, item4 is in the list')
else:
print('no, item4 is not in the list')
if value in list:
#do stuff
#Also to check if it doesn't contain
if value not in list:
#do stuff
# app.py
listA = ['Stranger Things', 'S Education', 'Game of Thrones']
if 'Dark' in listA:
print("Yes, 'S Eductation' found in List : ", listA)
else:
print("Nope, 'Dark' not found in the list")
listttt = ["eee", "yee"]
if "yee" in listttt:
print("yee")
else:
print("no.")