Python for Moon

Asked 2 years ago, Updated 2 years ago, 53 views

Trying to create a program to find specific characters in a string Please point out the error

s=input('sentence:')
w=input ('Find words:')
for i in s:
     if i==w:
          print (i+'found at position')
     else:
           print (w+'No Characters')

python for

2022-09-22 18:08

1 Answers

for i in s:

In this loop, i takes out one character, one character from s. If w is more than two characters, the ifi==w: condition will never be satisfied.


2022-09-22 18:08

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.