Skip to content

Commit 7b425d6

Browse files
committed
Enhance comments in 05_input.py to clarify usage of input() function and handling of user data
1 parent 6a6dad2 commit 7b425d6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

01_basic/05_input.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33
# La función input() permite obtener datos del usuario a través de la consola.
44
###
55

6+
# Para obtener datos del usuario se usa la función input()
7+
# La función input() recibe un mensaje que se muestra al usuario
8+
# y devuelve el valor introducido por el usuario
69
nombre = input("Hola, ¿cómo te llamas?\n")
710
print(f"Hola {nombre}, encantado de conocerte")
811

12+
# Ten en cuenta que la función input() devuelve un string
13+
# Así que si queremos obtener un número se debe convertir el string a un número
914
age = input("¿Cuántos años tienes?\n")
1015
age = int(age)
1116
print(f"Tienes {age} años")
1217

18+
# La función input() también puede devolver múltiples valores
19+
# Para hacerlo, el usuario debe separar los valores con una coma
1320
print("Obtener múltiples valores a la vez")
1421
country, city = input("¿En qué país y ciudad vives?\n").split()
1522

0 commit comments

Comments
 (0)