Cian :
I'm having trouble entering data I keep getting the error "invalid literal for int() with base 10"
def strings_to_ints(linelist):
outputlist = []
for item in linelist:
outputlist.append(int(item))
return outputlist
def process_line(line):
global box_count, ship_class
linestrings = line.split()
name = linestrings[0]
linevalues = strings_to_ints(linestrings[:1])
quantity = linevalues [0]
ship_class = linevalues [1]
box_count = box_count + quantity
order_price = compute_price(quantity)
discounted_price = compute_discounted_price()
tax = compute_tax(discounted_price)
ship_cost = compute_ship_cost(quantity)
billed_amount = discounted_price + tax + ship_cost
outlist = [quantity, order_price, compute_discount(), tax, ship_cost, billed_amount]
return name, outlist
def enter_data():
global order_count
line = input('Enter Name, Quantity, and Ship Class: >>> ')
name, outlist = process_line(line)
order_count = order_count + 1
print(name, outlist))
I know I that the name should somehow be separate from the numbers but I can't figure out where to do this.
I added the most of code, all of the relevant parts I think. Hopefully, it's easier to understand
difurious :
linevalues = strings_to_ints(linestrings[:1])
should be:
linevalues = strings_to_ints(linestrings[1:])
Assuming that both Quantity and ship class are integers, and are space separated
i.e. Test 1 2
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=276598&siteId=1