Python Forum
Searching for parts of a string or word
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Searching for parts of a string or word
#2
Your code as currently written is looking at the list variable string1, which you have explicitly defined, to see if it contains either text or word. So, you are only going to get the "Word found" output if you enter "This is awesome" or "awesome", since those are the two values found in string1.

I'm not 100% sure of your expectations, but it sounds like maybe you want to search text to see if it contains word. You can do that by changing the first line of your search function.
Reply


Messages In This Thread
RE: Searching for parts of a string or word - by GOTO10 - Mar-14-2021, 03:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation A function that takes a word and a string of forbidden letters pooyan89 5 4,837 Jun-12-2019, 09:44 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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