Finding a hello word in a different string, which it has hello in it

2024/7/7 6:03:33

I should find a 'hello' word in a string, which I gave it from input. Here is the code that I currently have, but I cannot match 'hello' with the character list.

mylist = 'it can be any letter plus hello in it'
for letter in mylist:if letter in key:mylist2+=letter
print(mylist2)
mylist2 = ['h', 'h', 'e', 'l', 'l', 'l', 'l', 'l', 'o', 'o']
Answer

here is the code which I think that can find the 'hello' word in strings.

firststring = input() #ahhellllloou
to_find = "hello"def check_string(firststring, to_find):c = 0for i in firststring:#print(i)if i == to_find[c]:c += 1if c == len(to_find):return "YES"return "NO"print(check_string(firststring, to_find))
https://en.xdnf.cn/q/120160.html

Related Q&A

Building Permutation with Python

Im trying to write a programme to get all permutations of a string of letter using recursion. As Im a beginner in Python, I learnt about recursion with examples like Fibonacci Number and Factorial. I u…

Python: Is There a builtin that works similar but opposite to .index()?

Just a forewarning: I just recently started programming and Python is my first language and only language so far.Is there a builtin that works in the opposite way of .index()? Im looking for this beca…

Get a subset of a data frame into a matrix

I have this data frame:I want just the numbers under August - September to be placed into a matrix, how can I do this?I tried this cf = df.iloc[:,1:12] which gives me but it gives me the headers as w…

Get Pairs of List Python [duplicate]

This question already has answers here:How can I iterate over overlapping (current, next) pairs of values from a list?(13 answers)Closed 9 years ago.c = [1,2,3,4,5,6,7,8,9,10]for a,b in func(c):doSome…

Python - make a list

How can I turn something like this: (not a file)Edit: Its what I get when I print this:adjusted_coordinate_list = str(adjusted_X_coordinate) + , + str(Y_coordinate)1,1 1,2 1,3 1,4 1,5into this:[1,1,1,2…

Error while running test case

I need to test my code below. I am using one test to see if it is working or not. but dont know what exactly I should pass as a parameter in the test code. Please see the test code at the end and pleas…

How to run something on each line of txt file?

I am trying to get this to run on each line of a .txt file.D1 =int(lines[0])*10 D2 =int(lines[1])*9 D3 =int(lines[2])*8 D4 =int(lines[3])*7 D5 =int(lines[4])*6 D6 =int(lines[5])*5 D7 =int(lines[6])*4 D…

Python np.nditer() - ValueError: Too many operands

I have a few methods which pass different amount of messy data to this function to combine headers with data and return a list of dictionaries:def zip_data(self, indicator_names, indicator_values):valu…

Python 3 - Find the Mode of a List

def mode(L):shows = []modeList = []L.sort()length = len(L)for num in L:count = L.count(num)shows.append(count)print List = , LmaxI = shows.index(max(shows))for i in shows:if i == maxI:if modeList == []…

Create list of sublists [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 9 years ago.Improve…