Day 4: Using Lists

We are checking out how to include input-strings to a list. Interestingly the append()-function for the list only takes one argument/variable at a time.

This program would also not be possible with a tuple – because tuples can’t be changed after initialization.

 

data = []

name = input("Enter your name: ")
age = input("Your age please: ")
city = input("The city you live in: ")

data.append(name)
data.append(age)
data.append(city)

print("Hello " + data[0] + "! You are " + data[1] + " years old and live in " + data[2] + ".")

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.