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
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:
x = "Nancy"
You should see this output:
Try the exercises below
- Make a program that displays your favourite actor/actress.
- Try to print the word ‘lucky’ inside s.
- Try to print the day, month, year in the form “Today is 2/2/2016”.