Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Work with Strings | Introduction to Python 1/2
Introduction to Python for Data Analysis

book
Work with Strings

Strings are the standard way to store text. We can use it for storing users' emails, names, etc. You can keep it in different ways.

  • The first way is:

string = 'Strings are easy'
print(string)
12
string = 'Strings are easy' print(string)
copy
  • The second way is:

string = "Strings are easy"
print(string)
12
string = "Strings are easy" print(string)
copy
  • The third way is:

string = '''
Strings are easy
'''
print(string)
1234
string = ''' Strings are easy ''' print(string)
copy
  • The fourth way is:

string = """
Strings are easy
"""
print(string)
1234
string = """ Strings are easy """ print(string)
copy

The first two ways are the most common, and the third and the fourth are used for storing several lines of code.

If you want to put a quotation mark inside the quotes, you can put an ordinary quotation mark inside a double one or vice versa.

string_1 = "I've never learned Python"
string_2 = 'I"ve never learned Python'
print(string_1)
print(string_2)
1234
string_1 = "I've never learned Python" string_2 = 'I"ve never learned Python' print(string_1) print(string_2)
copy
question mark

Choose the INCORRECT ways to define the string.

Select the correct answer

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 11

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt