Strings in Python - Python Tutorial - w3Schools - Ch#09 English

Published: 18 July 2022
on channel: w3Schools Tutorials
197
2

Strings in python are surrounded by either single quotation marks, or double quotation marks.

'hello' is the same as "hello".

Assigning a string to a variable is done with the variable name followed by an equal sign and the string.
You can assign a multiline string to a variable by using three quotes Or three single quotes.

Strings are Arrays
Like many other popular programming languages, strings in Python are arrays of bytes representing unicode characters.

However, Python does not have a character data type, a single character is simply a string with a length of 1.

Square brackets can be used to access elements of the string.

Looping Through a String
Since strings are arrays, we can loop through the characters in a string, with a for loop.

String Length
To get the length of a string, use the len() function.

Check String
To check if a certain phrase or character is present in a string, we can use the keyword in.

Check if NOT
To check if a certain phrase or character is NOT present in a string, we can use the keyword not in.


On this page of the site you can watch the video online Strings in Python - Python Tutorial - w3Schools - Ch#09 English with a duration of hours minute second in good quality, which was uploaded by the user w3Schools Tutorials 18 July 2022, share the link with friends and acquaintances, this video has already been watched 197 times on youtube and it was liked by 2 viewers. Enjoy your viewing!