Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] list content check
#2
(Jan-03-2024, 02:10 PM)paul18fr Wrote: is there a simplier way to test a list content?b Smile
(solution#2 does the job in a single line)
It's unclear what exactly you try to check
>>> spam = ['xxx', 'yyy', 'zzz']
>>> 'zzz' in spam
True
>>> any('zz' in item for item in spam)
True
>>> any('aa' in item for item in spam)
False
>>>
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
[solved] list content check - by paul18fr - Jan-03-2024, 02:10 PM
RE: list content check - by buran - Jan-03-2024, 02:46 PM
RE: list content check - by paul18fr - Jan-03-2024, 04:02 PM
RE: list content check - by deanhystad - Jan-03-2024, 09:59 PM
RE: list content check - by Pedroski55 - Jan-04-2024, 10:01 AM
RE: list content check - by paul18fr - Jan-04-2024, 10:16 AM
RE: [solved] list content check - by deanhystad - Jan-04-2024, 11:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with to check an Input list data with a data read from an external source sacharyya 3 573 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  Response.json list indices must be integers or slices, not str [SOLVED] AlphaInc 4 6,718 Mar-24-2023, 08:34 AM
Last Post: fullytotal
  [SOLVED] [sqilte3] Check if column not empty? Winfried 5 1,223 Jan-28-2023, 12:53 PM
Last Post: Winfried
  Check if clients are online with ips stored in json [SOLVED] AlphaInc 6 2,665 Jun-27-2022, 08:28 AM
Last Post: AlphaInc
  check if element is in a list in a dictionary value ambrozote 4 2,117 May-11-2022, 06:05 PM
Last Post: deanhystad
  Loop through list of ip-addresses [SOLVED] AlphaInc 7 4,232 May-11-2022, 02:23 PM
Last Post: menator01
  [solved] Basic question on list matchiing paul18fr 7 1,982 May-02-2022, 01:03 PM
Last Post: DeaD_EyE
  How to check if a list is in another list finndude 4 1,951 Jan-17-2022, 05:04 PM
Last Post: bowlofred
  [solved] Sort list paul18fr 5 2,980 Aug-18-2021, 06:34 AM
Last Post: naughtyCat
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,595 Aug-12-2021, 04:25 PM
Last Post: palladium

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020