Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Check String | Strings
Python Data Types

book
Check String

Very often it hits that we need to check for the presence of some character or word in the string, and in order to realize this, we should use such a key word as in. As a result, we get a boolean value: True if such a character or substring is present in the string, and False - in the opposite case. For a better understanding, let's look at an example.

123
string = 'Pear Lime Banana' print('Lime' in string) print('Mango' in string)
copy
Uppgift

Swipe to start coding

You have a string. You should check that this line contains such substrings Lorem, python, consectetur. If there is such a substring, then calculate its length.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 9

Fråga AI

expand
ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

some-alt