Advertisement
elenaD

Set instead a list

Feb 18th, 2025
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | Software | 0 0
  1. import time
  2.  
  3. devices = {"iphone", "android", "radio", "tv", "tablet", "pc", "laptop"}
  4.  
  5. user_input = input("Enter a device name: ").strip().lower()
  6.  
  7. start_time = time.time()
  8. is_present = user_input in devices
  9. end_time = time.time()
  10.  
  11. if is_present:
  12.     print(f"'{user_input}' is in the device list.")
  13. else:
  14.     print(f"'{user_input}' is NOT in the device list.")
  15.  
  16. print(f"Time taken for the check: {end_time - start_time:.10f} seconds")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement