This question already has answers here:
Does "IndexError: list index out of range" when trying to access the N'th item mean that my list has less than N items?
(7 answers)
Closed 1 year ago.
ItemNumber = []
ItemDescription = []
ItemReserveprice = []
ItemBids = []
Item = 0
Buyerno = 1
BuyerNumber = []
sellercount = 0
whoareyou = input("Are you a seller or a buyer? enter s/b ")
if whoareyou == "s":
choice1 = input("Do you want to enter your seller ID?: ")
if choice1 == "yes":
testItemNumber = input("Please enter your seller id in the form 00N: ")
for i in ItemNumber:
if i == testItemNumber:
print("Please enter another seller ID")
ItemNumber.insert(sellercount,int(input("Enter your seller ID again, please make sure it is in the form 00N: ")))
while Item < 11:
ItemDescription.insert(Item,input("Enter your item description: "))
ItemReserveprice.insert(Item,int(input("Enter your reserve price: ")))
ItemBids.insert(Item,0)
Item = Item + 1
if choice1 == "no":
ItemNumber.insert(sellercount,('00' + str(sellercount+1)))
print (ItemNumber[sellercount],"is your seller ID")
while Item < 10:
print ("Now enter Item number",Item+1)
ItemDescription.insert(Item,input("Enter your item description: "))
ItemReserveprice.insert(Item,int(input("Enter your reserve price: ")))
ItemBids.insert(Item,0)
Item = Item + 1
print ("Auction Starts!")
print ("You are now in the buyer screen")
BuyerNumber.insert(Buyerno,('aa' + str(Buyerno)))
print ("Your buyer number is",BuyerNumber)
or i in range (0,10):
print ("The Item number of item number ",i+1,"is",ItemNumber[i],"The Description is",ItemDescription[i],"The reserve price is",ItemReserveprice[i])
choice2 = input("What item do you want to bid for?, enter the item number")
if i try to print any element from the array that is not the first one i get that error. For example if i try to print ItemNumber[2] or anything above so i cant print ItemNumber[i] as when i goes 2 to i get that error. I'm trying a task for an auction specifically the 2019 June Computer science pre release paper.Im a beginner so please dont bash this is my 2nd month. PS: the code is not completed
Because in the code
ItemNumber.insert(sellercount,('00' + str(sellercount+1)))
only 1 record has been added into ItemNumber.
So access ItemNumber[i] when i in (2..10) will cause exception.
I try to modify the code, add the item number into ItemNumber as below:
ItemNumber = []
ItemDescription = []
ItemReserveprice = []
ItemBids = []
Item = 0
Buyerno = 1
BuyerNumber = []
sellercount = 0
# NOTE: use SellerNumber to store the seller number
SellerNumber = []
whoareyou = input("Are you a seller or a buyer? enter s/b ")
if whoareyou == "s":
choice1 = input("Do you want to enter your seller ID?: ")
if choice1 == "yes":
testItemNumber = input("Please enter your seller id in the form 00N: ")
for i in ItemNumber:
if i == testItemNumber:
print("Please enter another seller ID")
ItemNumber.insert(sellercount,int(input("Enter your seller ID again, please make sure it is in the form 00N: ")))
while Item < 11:
ItemDescription.insert(Item,input("Enter your item description: "))
ItemReserveprice.insert(Item,int(input("Enter your reserve price: ")))
ItemBids.insert(Item,0)
Item = Item + 1
if choice1 == "no":
# NOTE: insert the seller number
SellerNumber.insert(sellercount,('00' + str(sellercount+1)))
print (SellerNumber[sellercount],"is your seller ID")
while Item < 10:
print ("Now enter Item number",Item+1)
# NOTE: insert the item number into ItemNumber
ItemNumber.insert(Item, 'ITEM_NUMBER' + str(Item))
ItemDescription.insert(Item,input("Enter your item description: "))
ItemReserveprice.insert(Item,int(input("Enter your reserve price: ")))
ItemBids.insert(Item,0)
Item = Item + 1
print ("Auction Starts!")
print ("You are now in the buyer screen")
BuyerNumber.insert(Buyerno,('aa' + str(Buyerno)))
print ("Your buyer number is",BuyerNumber)
for i in range (0,10):
print ("The Item number of item number ",i+1,"is",ItemNumber[i],"The Description is",ItemDescription[i],"The reserve price is",ItemReserveprice[i])
choice2 = input("What item do you want to bid for?, enter the item number")
And it works:
Related
I want the user to select a string value from a list and the quantity of that string they want.
Using those two factors, I want to multiply the the amount of the item they chose with the value of that item and add that to their balance.
import random
from math import fsum
item_val = {
"Common": 10,
"Uncommon": 25,
"Rare": 50,
"Epic": 100,
"Legendary": 250,
"Exotic": 500,
}
def item_trading():
balance = []
init_bal = random.randint(10, 500)
balance.append(init_bal)
print(f"Your starting balance is: {balance}. ")
while True:
which_item = input("Which item would you like to purchase?: ")
which_item = str(which_item)
if which_item not in item_val:
print("That item doesn not exist. Please try again. ")
continue
else:
print(f"You want to purchase {which_item} rarity of items. ")
num_of_items = input(f"How many {which_item} items would you like to purchase?: ")
num_of_items = int(num_of_items)
print(f"You have purchased {num_of_items} {which_item} items! ")
for rarity,val in item_val.items():
balance.append(-(num_of_items)*(val))
print(f"You current balance is: {fsum(balance)} ")
break
break
item_trading()
However, "balance.append(-(num_of_items)*(val))" only uses the first value ("Common" value) which is 10, so even if the user selected a "Rare" value (50) it only multiplies by 10.
How would I go about doing this? Thanks in advance!
You don't need to loop over item_vals.items(), just use item_vals[which_item]
init_bal = random.randint(10, 500)
balance = [init_bal]
def item_trading():
print(f"Your starting balance is: {balance}. ")
which_item = input("Which item would you like to purchase?: ")
which_item = str(which_item)
if which_item not in item_val:
print("That item doesn not exist. Please try again. ")
continue
print(f"You want to purchase {which_item} rarity of items. ")
num_of_items = input(f"How many {which_item} items would you like to purchase?: ")
num_of_items = int(num_of_items)
print(f"You have purchased {num_of_items} {which_item} items! ")
balance.append(-num_of_items * item_vals[which_item]
print(f"Your current balance is: {fsum(balance)} "
break
item_trading()
Also, the initialization of the balance list should not be in the function. If it's in the function, you reset the balance every time you call the function, instead of keeping a running balance.
Just starting out with python functions (fun_movies in functions.py) and I can't seem to get out (via "no" or False) once in the loop:
main_menu.py
from functions import *
def menu():
print("Press 1 for movies.")
print("Press 2 to exit.")
menu()
option = int(input("Input a number: "))
while option != 0:
#try:
if option == 1:
fun_movies()
elif option == 2:
print("Goodbye! ")
break
else:
print ("Wrong input")
functions.py
global movies
movies = {}
def fun_movies():
name = input("Insert movie name: ")
genre = input("Input genre: ")
movies [name] = [genre]
a = True
while a:
query = input("Do you want to input another movie? (yes/no) ")
if query == "yes":
name = input("Insert movie name: ")
genre = input("Input genre: ")
movies_if = {}
movies_if [name] = [genre]
movies.update(movies_if)
elif query == "no":
break
else:
print ("Wrong input!")
return movies
Code works fine when not called via import. When called via import (in main_menu.py), it keeps asking for infinite movies even when I input a "no". I can't find a way to exit the loop. Initially I had a "pass" but that didn't work.
Thanks in advance!
global movies
movies = {}
def fun_movies():
name = input("Insert movie name: ")
genre = input("Input genre: ")
movies [name] = [genre]
a = True
while a:
query = input("Do you want to input another movie? (yes/no) ")
if query == "yes":
name = input("Insert movie name: ")
genre = input("Input genre: ")
movies_if = {}
movies_if [name] = [genre]
movies.update(movies_if)
elif query == "no":
a = False
else:
print ("Wrong input!")
return movies
A few things:
Firstly, you don't need a==True as this statement returns True when a is True and False when a is False, so we can just use a as the condition.
Secondly, only use the input at the start of the loop as you want to ask once per iteration
Thirdly, place your return outside the loop so you only return when a==False and you don't want to input another movie.
edit:
main file>
from functions import *
def menu():
print("Press 1 for movies.")
print("Press 2 to exit.")
menu()
option = int(input("Input a number: "))
while option != 0:
if option == 1:
fun_movies()
elif option == 2:
print("Goodbye! ")
break
else:
print ("Wrong input")
option = int(input("Input a number"))
global movies
movies = {}
def fun_movies():
name = input("Insert movie name: ")
genre = input("Input genre: ")
movies[name]= genre
a = True
while a:
query = input("Do you want to input another movie? (yes/no) ")
if query == "yes":
name = input("Insert movie name: ")
genre = input("Input genre: ")
movies_if = {}
movies_if [name] = genre
movies.update(movies_if)
elif query == "no":
break
else:
print ("Wrong input!")
# continue
return movies
print(fun_movies())
Hope It works for you!
I am looking to ask the user to pick from the items list. I figured I could ask the user a designated amount of questions ("Enter your Items: ") and add all of the questions up (like q1, q2, q3, etc.).
But I would rather allow the user to pick an indefinite amount of items until they hit Enter and break the loop. THEN add all of the prices from their entry, as long as it matches the fmPrices dict.
import math
dollar = "$"
items = ["Eggs","Milk","Chips","Butter","Grapes","Salsa","Beer"]
items.sort()
choice = ("Choose from the following items:")
print (choice)
print (items)
fmPrices = {
"Eggs" : 2.99,
"Milk": 3.99,
"Chips": 4.29,
"Butter": 3.29,
"Grapes": 3.49,
"Salsa": 40.99,
"Beer": 1.99
}
while True:
q1 = input("Enter your item: ")
if q1 == '':
break
else:
input("Enter your item: ")
print ("Your estimated cost is: ")
total = round(fmPrices[q1],2)
print ("{}""{}" .format(dollar, total))
mylist = []
total = 0
while True:
q1 = input("Enter your item: ")
if q1 == '':
break
if q1 not in fmPrices:
print("Item is not in the list")
else:
mylist.append(q1)
total += fmPrices[q1]
print ("Your estimated cost is: ")
print( "$", round(total,2) )
For example
cost = 0
while True:
q1 = input("Enter your item: ")
if q1 == '':
break
price = fmPrices.get(q1)
if price == None:
print("Item not available")
else:
cost += price
total = round(cost,2)
print(f"Your estimated cost is: {dollar}{total}")
I am currently trying to create a code that will help people in shops who need to:
Calculate the item with the best value (out of up to 10 items)
Calculate the sale price
Calculate the discount
Create a shopping cart or a shopping list
Print a receipt (just by simply showing the items, the quantity and the the cost of each products, then showing the total cost at the bottom)
I have only worked on the top four points above, but I have not a single idea on how to create and print a receipt. Here's my code so far:
#This part greets the user, and lets the user know that the application has started
print("Hello there!")
#This starts off the loop, but this variable may be changed later on
cont = "yes"
#This is the actual loop
while cont == "yes" or cont == "Yes" or cont == "YES":
print("Choose an option below:")
#This shows the options
print("1) Calculate the value of different product sizes")
print("2) Calculate the sale price")
print("3) Calculate the discount")
print("4) Create a shopping list")
print("5) Exit")
#This part lets the user choose what they would like to do
option = float(input("Choose an option (1/2/3/4/5): "))
#This is what happens if the user chooses Option 4
if option == 4:
#This is the "Shopping list" part of the application below
import os,sys,time
sl = []
try:
f = open("Your_shopping_list.txt","r")
for line in f:
sl.append(line.strip())
f.close()
except:
pass
def mainScreen():
print("Your list contains",len(sl),"items.")
print("Please choose from the following options:")
print("1) Add to the list")
print("2) Delete from the list")
print("3) View the list")
print("4) Quit the program")
choice = input("Enter your choice here (1/2/3/4): ")
if len(choice) > 0:
if choice == "1":
addScreen()
elif choice == "2":
deleteScreen()
elif choice == "3":
viewScreen()
elif choice == "4":
sys.exit()
else:
mainScreen()
else:
mainScreen()
def addScreen():
print("Please enter the name of the item that you want to add.")
print("Press ENTER to return to the main menu.")
item = input("Item: ")
if len(item) > 0:
sl.append(item)
print("Item added.")
saveList()
time.sleep(1)
addScreen()
else:
mainScreen()
def viewScreen():
for item in sl:
print(item)
print("Press ENTER to return to the main menu")
input()
mainScreen()
def deleteScreen():
global sl
count = 0
for item in sl:
print(count, " - ", item)
count = count + 1
print("Press ENTER to return to the main menu.")
print("Which item do you want to remove?")
choice = input("Enter your choice here: ")
if len(choice) > 0:
try:
del sl[int(choice)]
print("Item deleted...")
saveList()
time.sleep(1)
except:
print("Invalid number")
time.sleep(1)
deleteScreen()
else:
mainScreen()
def saveList():
f = open("Your_shopping_list.txt", "w")
for item in sl:
f.write(item)
f.close()
mainScreen()
#This is what happens if the user chooses Option 1
#This is the part that calculates the value of up to 10 products
if option == 1:
#This notifies the user that there can only be up to 10 product sizes entered
print("Please note: This code can only take up to 10 product sizes.")
#This asks the user how many products there are
products = int(input("How many products are there? "))
#This is just in case the user still types that there are over 10 products
if products > 10:
print("This code can only take up to 10 product sizes.")
print("Please enter only up to 10 product sizes below.")
if products <= 1:
#This tells the user that they must enter at least 2 product sizes to compare them
print("You must enter at least two product sizes to compare.")
if products >= 1:
#This asks for information because the user may just be looking for the $/g.
cost1 = float(input("Cost of first product($): "))
mass1 = float(input("Mass of first product(g): "))
ans1 = cost1/mass1
a = ans1
#This part substitutes undefined variables with a blank
#This is in case the number of sizes being compared doesn't reach 2 to 10
ans2 = ""
ans3 = ""
ans4 = ""
ans5 = ""
ans6 = ""
ans7 = ""
ans8 = ""
ans9 = ""
ans10 = ""
#This is for when there are two or more product sizes
if products >= 2:
cost2 = float(input("Cost of second product($): "))
mass2 = float(input("Mass of second product(g): "))
ans2 = cost2/mass2
if a > ans2:
a = ans2
#This is for when there are three or more product sizes
if products >= 3:
cost3 = float(input("Cost of third product($): "))
mass3 = float(input("Mass of third product(g): "))
ans3 = cost3/mass3
if a > ans3:
a = ans3
ans4 = ""
ans5 = ""
ans6 = ""
ans7 = ""
ans8 = ""
ans9 = ""
ans10 = ""
#This is for when there are four or more product sizes
if products >= 4:
cost4 = float(input("Cost of fourth product($): "))
mass4 = float(input("Mass of fourth product(g): "))
ans4 = cost4/mass4
if a > ans4:
a = ans4
ans5 = ""
ans6 = ""
ans7 = ""
ans8 = ""
ans9 = ""
ans10 = ""
#This is for when there are five or more product sizes
if products >= 5:
cost5 = float(input("Cost of fifth product($): "))
mass5 = float(input("Mass of fifth product(g): "))
ans5 = cost5/mass5
if a > ans5:
a = ans5
ans6 = ""
ans7 = ""
ans8 = ""
ans9 = ""
ans10 = ""
#This is for when there are six or more product sizes
if products >= 6:
cost6 = float(input("Cost of sixth product($): "))
mass6 = float(input("Mass of sixth product(g): "))
ans6 = cost6/mass6
if a > ans6:
a = ans6
ans7 = ""
ans8 = ""
ans9 = ""
ans10 = ""
#This is for when there are seven or more product sizes
if products >= 7:
cost7 = float(input("Cost of seventh product($): "))
mass7 = float(input("Mass of seventh product(g): "))
ans7 = cost7/mass7
if a > ans7:
a = ans7
ans8 = ""
ans9 = ""
ans10 = ""
#This is for when there are eight or more product sizes
if products >= 8:
cost8 = float(input("Cost of eighth product($): "))
mass8 = float(input("Mass of eighth product(g): "))
ans8 = cost8/mass8
if a > ans8:
a = ans8
ans9 = ""
ans10 = ""
#This is for when there are nine or more product sizes
if products >= 9:
cost9 = float(input("Cost of ninth product($): "))
mass9 = float(input("Mass of ninth product(g): "))
ans9 = cost9/mass9
if a > ans9:
a = ans9
ans10 = ""
#This is for when there are ten or more product sizes
if products >= 10:
cost10 = float(input("Cost of tenth product($): "))
mass10 = float(input("Mass of tenth product(g): "))
ans10 = cost10/mass10
if a > ans10:
a = ans10
#There's nothing for 10+ sizes for there is no loop for it'll make the code too long
#This tells the user the which product size(s) is/are the ones with the best value
#This tells the user the final result
if products >= 1:
print("The product(s) with the best value is/are the below product number(s):")
if ans1 == a:
print(1)
if ans2 == a:
print(2)
if ans3 == a:
print(3)
if ans4 == a:
print(4)
if ans5 == a:
print(5)
if ans6 == a:
print(6)
if ans7 == a:
print(7)
if ans8 == a:
print(8)
if ans9 == a:
print(9)
if ans10 == a:
print(10)
#This tells the user the cost per gram of the product(s) with the best value is/are
print("The cost per gram is $", a, "/ g")
#This tells the user to pick the size with best quality if multiple are above
#Sometimes, items with the best value may not have the best quality.
print("If there are multiple options above, choose the one with best quality.")
#This is what happens if the user chooses Option 2
#This calculates the price after a discount
if option == 2:
#This asks for the ticket (original) price of a specific product
p = float(input('The ticket (original) price($): '))
#This asks for the discount (in percentage) of a specific product
d = float(input('The discount(%): '))
#This then puts the information together and calculates the discount...
s = (d*0.01)
ps = (p*s)
answer = (p - ps)
answer2 = str(round(answer, 2))
print('The discount is $', ps)
#... and also the final discounted price.
#Finally, it tells the user the result
print('The final price is $', answer2)
#This is what happens if the user chooses Option 3
#This calculates the discount (in percentage)
if option == 3:
#This collects information about what the ticket (original) price was
o = float(input('The ticket (original) price($): '))
#This asks what the price of the product after the discount is
#Then it takes all the information, puts them together and calculates the discount(%)
d = float(input('Price after the discount($): '))
p = 100/(o/d)
p = str(round(p, 2))
#Finally, it tells the user the result
print('The percentage discount is', p,'%')
#This is the final option, which is for the user to quit using this application
if option == 5:
#This asks the user one last time in case they accidentally pressed 5.
exit = input("Are you sure you want to exit? (Yes/No): ")
#There are three versions of "Yes" to make the application more user-friendly
if exit == "yes":
#"Thank you and goodbye" thanks the user for using this application
#Then, it says goodbye and ends the application
print("Thank you and goodbye!")
cont = 'no'
if exit == "Yes":
print("Thank you and goodbye!")
cont = 'no'
if exit == "YES":
print("Thank you and goodbye!")
cont = 'no'
#But if exit doesn't equal "Yes" or "yes" or "YES", then cont still equals "yes".
#And if cont = "yes", then the loop restarts.
#This is if the user doesn't choose any of the above and enters an invalid input
elif option != 1:
if option != 2:
if option != 3:
if option != 4:
if option != 5:
print('Invalid input')
#This asks if the user would like to continue or quit
cont = input('Continue? (Yes/No): ')
#To make the application more user-friendly, there are again three versions of "No"
if cont == 'No':
#"Thank you and goodbye" thanks the user for using this application
#Then, it says goodbye and ends the application
print("Thank you and goodbye!")
if cont == 'no':
print("Thank you and goodbye!")
if cont == 'NO':
print("Thank you and goodbye!")
Here are some improvements:
1.Use a class instead to store different related things
class Ingredient():
def __init__(self, name):
self.name = name
self.cost = float(input(f"Cost of {self.name}($): "))
self.mass = float(input(f"Mass of {self.name}(g): "))
self.ans = cost6 / mass6
2.Then you don't need ten answer variables. You can use a list
wrong:
ans2 = ""
ans3 = ""
...
option1 = input()
option2 = input()
...
right:
ingredients = []
for i in range(0, products):
ing = Ingredient("Product " + str(i + 1))
ingredients.append(ing)
3.Use lists to compare different options
elif option != 1:
if option != 2:
if option != 3:
if option != 4:
if option != 5:
can be replaced by
if option not in [1, 2, 3, 4, 5]:
and
if exit == "yes":
print("Thank you and goodbye!")
...
could be
if exit in ["yes", "YES", "Yes"]:
print("Thank you and goodbye!")
cont = 'no'
same for cont == No
Then showing a receipt will be easy
totalCost = 0
for item in ingredients:
print(item.name, str(item.cost), str(item.mass))
totalCost += item.cost
print(totalCost + "$")
Here is a solution (I hope this answers your question):
print ('How many items are you planning to buy?')
times = int(input('>> '))
def question(times):
grocery_list = {}
print ('Enter grocery item and price.')
for i in range(times):
key = input('Item %d Name: ' % int(i+1))
value = input('Item %d Price: $' % int(i+1))
grocery_list[key] = value
print(grocery_list)
totalPrice = sum([float(grocery_list[item]) for item in grocery_list])
print('Total: ${:.2f}'.format(totalPrice))
question(times)
print('< >')
Maybe consider using this as a solution, as it is an improved version of user13329487 's code:
def inputGroceries():
groceries = list()
while True:
try:
i = len(groceries)
name = input('Item #{} name: '.format(i))
if name == '':
break
price = float(input('Item #{} price: $'.format(i)))
quantity = int(input('Item #{} quantity: '.format(i)))
except ValueError:
print('Error: invalid input..')
continue
groceries.append((name, price, quantity))
return groceries
print("Enter items, price and quantity (end list by entering empty name):")
groceries = inputGroceries()
for item in groceries:
print('{} x {} (${:.2f} PP)'.format(item[2], item[0], item[1]))
totalPrice = sum([item[1] * item[2] for item in groceries])
print(30*'-')
print('Total: ${:>22.2f}'.format(totalPrice))
I am trying to create code to pull from a data sheet. My goal is to find the longest song, songs by year, and songs by an artist. Problem is, that when I run what I currently have I get a value returned of 0. Obviously this is not correct. What ways can I do to solve this? I have linked the data sheet here. Click here!
def longest_song():
pass
def songs_by_year(year):
total=0
with open('music.csv', 'r') as f:
for line in f:
time = line.split(",")
song = time[34]
if song == year:
total = total + 1
return total
def all_songs_by_artist(artist):
total = int(0)
data = open("music.csv", "r")
for line in data:
name = line.split(",")
song = name[2]
if song == artist:
total = total + 1
return total
# --------------------------------------
def menu():
print()
print("1. Identify longest song.")
print("2. Identify number of songs in a given year.")
print("3. Identify all songs by a given artist.")
print("4. You choose something that is interesting and non-trivial.")
print("5. Quit.")
# --------------------------------------
def main():
choice = 0
while (choice != 5):
menu()
choice = int(input("Enter your choice: "))
if (choice == 1):
longest_song()
elif (choice == 2):
year = int(input("Enter desired year: "))
number = songs_by_year(year)
## print("The number of songs from", "{:,d}".format(number))
print(number)
elif (choice == 3):
artist = input("Enter name of artist: ").lower()
all_songs_by_artist(artist)
number = all_songs_by_artist(artist)
print("There are", "{:,d}".format(number))
elif (choice == 4):
pass
elif (choice != 5):
print("That is not a valid option. Please try again.")
# --------------------------------------
main()
You are converting input artist to lowercase but Not changing the artist from the file to lower case, thus no matches.
You are converting the Year to an int but not doing so to the year from the file.
It is difficult to tell if there are other issues, as your code sample is not indented properly.
I'm guessing but I suppose that it should look something like this.
def longest_song(): pass
def songs_by_year(year):
total=0
with open('music.csv', 'r') as f:
for line in f:
time = line.split(",")
song = time[34]
try:
if int(song) == year:
total = total + 1
except:
pass
return total
def all_songs_by_artist(artist):
total = int(0)
with open("music.csv", "r") as data:
for line in data:
name = line.split(",")
song = name[2].lower()
if song == artist:
total = total + 1
return total
# --------------------------------------
def menu():
print()
print("1. Identify longest song.")
print("2. Identify number of songs in a given year.")
print("3. Identify all songs by a given artist.")
print("4. You choose something that is interesting and non-trivial.")
print("5. Quit.")
# --------------------------------------
def main():
choice = 0
while (choice != 5):
menu()
choice = int(input("Enter your choice: "))
if (choice == 1):
longest_song()
elif (choice == 2):
year = int(input("Enter desired year: "))
number = songs_by_year(year)
## print("The number of songs from", "{:,d}".format(number))
print(number)
elif (choice == 3):
artist = input("Enter name of artist: ").lower()
all_songs_by_artist(artist)
number = all_songs_by_artist(artist)
print("There are", "{:,d}".format(number))
elif (choice == 4):
pass
elif (choice != 5):
print("That is not a valid option. Please try again.")
# --------------------------------------
main()