0
Hi guys. Need a little help here. I wanted to write a simple code for a program that greets the names entered.
I want the user to input the names of the people in his party. Possibly used by a hotel reservation system.Then the computer would simply print Hello+name+!, but would do so for each name. I am a total rookie and just trying to implement some of the stuff i have learnt so far. Any help is appreciated. I am stuck here. names[0]= input("Please input the names of the people in your group\n After each name press Enter.\n When finished, type ok\n") names[1]= input("\n") names[2]= input("\n") names[3]= input("\n") list(names) for i in names: print("Hello " + i+"!\n")
2 Réponses
+ 2
You must first define a list:
names = []
Then you can use the method of lists called append:
names.append(input())
+ 2
please edit the tags to include which language you are using because each language has a different syntax / style of doing what you want