Pythonda Tuple-da Elementin Olması
Verilmiş elementin siyahıda olub-olmadığını
in operatoru ilə öyrənmək olar:
tpl = ('a', 'b' 'c')
res = 'a' in tpl
print(res) # True çap edəcək
Elementin olmamasını yoxlamaq üçün
not in operatorundan istifadə etməlidir:
tpl = ('a', 'b' 'c')
res = 'a' not in tpl
print(res) # False çap edəcək
Tuple verilmişdir:
tpl = (2, 4, 6, 10)
Onda 8 rəqəminin olub-olmadığını yoxlayın.
Tuple verilmişdir:
tpl = ('abc', 'def')
Onda 'd' sətrinin olub-olmadığını yoxlayın.
Aşağıdakı kod verilmişdir:
tpl = ('1', '2', '3')
res = 1 not in tpl
print(res)
Konsola nə çap olunacağını deyin.
Aşağıdakı kod verilmişdir:
tpl1 = ('ac', '3', 4, 'bd', 5)
tpl2 = (1, 2, 3)
res1 = 4 in tpl1
res2 = 2 not in tpl2
print(res1)
print(res2)
Konsola nə çap olunacağını deyin.