Python Forum
Detecting String Elements in a List within Given Message
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detecting String Elements in a List within Given Message
#4
(Mar-18-2019, 08:13 PM)ichabod801 Wrote: Loop over the words in example_list, and test each one with message.startswith(word).

The problem that I'm still having with this is if I have two elements such as 'foo' and 'foo bar' that it will detect both of them if message is 'foo bar' because message still starts with 'foo'. I would just want it to detect and print 'foo bar'
Reply


Messages In This Thread
RE: Detecting String Elements in a List within Given Message - by Redicebergz - Mar-19-2019, 02:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  unable to remove all elements from list based on a condition sg_python 3 634 Jan-27-2024, 04:03 PM
Last Post: deanhystad
Question mypy unable to analyse types of tuple elements in a list comprehension tomciodev 1 607 Oct-17-2023, 09:46 AM
Last Post: tomciodev
  Checking if a string contains all or any elements of a list k1llcod3 1 1,314 Jan-29-2023, 04:34 AM
Last Post: deanhystad
  iterating and detecting the last Skaperen 3 1,216 Oct-01-2022, 05:23 AM
Last Post: Gribouillis
  How to change the datatype of list elements? mHosseinDS86 9 2,221 Aug-24-2022, 05:26 PM
Last Post: deanhystad
  Detecting float or int in a string Clunk_Head 15 5,128 May-26-2022, 11:39 PM
Last Post: Pedroski55
  ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 5,517 May-17-2022, 11:38 AM
Last Post: Larz60+
  module detecting if imported vs not Skaperen 1 1,765 Nov-19-2021, 07:43 AM
Last Post: Yoriz
  detecting a generstor passed to a funtion Skaperen 9 3,874 Sep-23-2021, 01:29 AM
Last Post: Skaperen
  Why am I getting list elements < 0 ? Mark17 8 3,386 Aug-26-2021, 09:31 AM
Last Post: naughtyCat

Forum Jump:

User Panel Messages

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