Any time you want to use text in Python, you are using strings. Python understands you want to use a string if you use the double-quotes symbol.

Once a string is created, you can simply print the string variable directly. You can access characters using block quotes.

Related course: Complete Python Bootcamp: Go from zero to hero in Python

String indexing

It creates string variable x. You can show it on the screen using the print() function.

Individual characters can be accessed using blockquotes, counting starts from zero. By using a colon you can create a substring.

Try the program below:

You should see this output:

python strings

Study drill

Try the exercises below



Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">