dannyk2
April 12th, 2018, 02:00 PM
Hope someone can help me out here
I have been following a tutorial for making a list in Python as follows:
I opened a terminal and typed: nano shopping.py
costs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
def sumCart(items):
totalCost = 0
for x in costs:
totalCost += x
return totalCost
print sumCart(costs)
Now when i call the above function in a terminal using: python shopping.py
275 is displayed
But when i try to open the same file in a terminal using: python3 shopping.py
An error is displayed as followed:
File "shopping.py", line 11
print sumCart(costs)
I know that i have tried to use two different versions of Python
But would someone tell me how i might get the above function
to display in Python3 please.
I have been following a tutorial for making a list in Python as follows:
I opened a terminal and typed: nano shopping.py
costs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
def sumCart(items):
totalCost = 0
for x in costs:
totalCost += x
return totalCost
print sumCart(costs)
Now when i call the above function in a terminal using: python shopping.py
275 is displayed
But when i try to open the same file in a terminal using: python3 shopping.py
An error is displayed as followed:
File "shopping.py", line 11
print sumCart(costs)
I know that i have tried to use two different versions of Python
But would someone tell me how i might get the above function
to display in Python3 please.