Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===================================================================================================
- # An example of creating an array/list using Python
- #===================================================================================================
- # Initialize variables and array / list
- count = 0; # initialize lcv / index of the name list/ array name[count]
- name = []; # creates an empty array
- #====================================================================================================
- # Create / Populate the name list/array using a while loop
- # Create a list of names to be stored simultaneously in RAM
- numItems = int(input("How many names do you wish to enter? ")); # establishes an ending value
- while (count < numItems): # "Enter name of Customer " [1]: "
- name.append(str(input("Enter name of Customer <last name, first name> " + \
- format("[" + format(count + 1, "2d") + "]: ", ">4s"))));
- count = count + 1; # updates the index - goes to next item in list such as name
- # end while loop
- #====================================================================================================
- # Displays all the items in the array / list such as a list of names...
- count = 0; # Reset beginning of counter
- print(); # displays a blank line
- print("-" * 60); # displays 60 dashes to make a separating line
- while (count < numItems):
- print("name "+ format("[" + format(count + 1, "2d") + "]: --> ", ">10s") + name[count]);
- count = count + 1;# updates the index - displays next item in list such as name
- # end while loop
- print("-" * 60); # displays 60 dashes to make a separating line
- #====================================================================================================
- #END PROGRAM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement