¡GoConqr estrena diseño! Cuéntanos qué te parece.

Módulo 11 de 24 · Texto

LAB

David Khieu

LAB

Estimated time

5-10 minutes

Level of difficulty

Easy

Objectives

  • becoming familiar with the print() function and its formatting capabilities
  • practicing coding strings
  • experimenting with Python code

Scenario

Write a one-line piece of code, using the print() function, as well as the newline and escape characters, to match the expected result outputted on three lines. 

swiftCopy code

print("I'm\n\"learning\"\n\"\"\"Python\"\"\"")

Output:

rustCopy code

I'm "learning" """Python"""

Explanation:

  • The newline character \n is used to break the output into three lines.
  • Double quotes " are used to enclose the strings "learning" and "Python". To include double quotes within a string, we need to escape them with a backslash \ to avoid interpreting them as the end of the string.
  • The single quote in "I'm" is not escaped because we used double quotes to enclose the entire string.

Instrucciones

Para avanzar en el curso, envía un intento de este test. Puedes enviarlo después de la última pregunta.

Ir al módulo elegido

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?