بررسی کنید که آیا مورد وجود دارد یا خیر(Check if Item Exists)

برای تعیین اینکه آیا یک مورد مشخص شده در یک لیست وجود دارد یا خیر، از کلمه کلیدی in استفاده کنید:




مثال


Check if "apple" is present in the list:



thislist = ["apple", "banana", "cherry"]

if "apple" in thislist:
  print("Yes, 'apple' is in the fruits list")