Find text in string

To find a text within a string, as a developer, I need to 'in'


Introduction

To find a text within a string the following code can be used:

text1 = "hello world again"
text2 = "world"
result = text2 in text1
print( result )

will print:

True

When we try again, but in a word that is not found:

text1 = "hello world again"
text2 = "abc"
result = text2 in text1
print( result )

will print:

False

Instructions

-

Python code



Terminal output


Written by: Bartek / Bartlomiej Rohard Warszawski

?>