Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.77 KB | None | 0 0
  1. #===================================================================================================
  2. # An example of creating an array/list using Python
  3. #===================================================================================================
  4. # Initialize variables and array / list
  5.  
  6. count = 0;  # initialize lcv / index of the name list/ array name[count]
  7. name = [];  # creates an empty array
  8.  
  9. #====================================================================================================
  10. # Create / Populate the name list/array using a while loop
  11. # Create a list of names to be stored simultaneously in RAM
  12. numItems = int(input("How many names do you wish to enter? ")); # establishes an ending value
  13.  
  14. while (count < numItems): # "Enter name of Customer " [1]: "
  15.     name.append(str(input("Enter name of Customer <last name, first name> " + \
  16.                         format("[" + format(count + 1, "2d") + "]: ", ">4s"))));
  17.     count = count + 1;  # updates the index - goes to next item in list such as name
  18.     # end while loop
  19.  
  20. #====================================================================================================
  21.  
  22. # Displays all the items in the array / list such as a list of names...
  23. count = 0; # Reset beginning of counter              
  24. print(); # displays a blank line
  25. print("-" * 60); # displays 60 dashes to make a separating line
  26. while (count < numItems):
  27.     print("name "+ format("[" + format(count + 1, "2d") + "]: --> ", ">10s") + name[count]);
  28.     count = count + 1;# updates the index - displays next item in list such as name
  29.     # end while loop
  30. print("-" * 60); # displays 60 dashes to make a separating line
  31.  
  32. #====================================================================================================
  33. #END PROGRAM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement