math = raw_input("Addition + or multiplication *.")
numbers = int(raw_input("How many numbers would you like to use?")
numbers_list = []
for input in range(numbers):
new_number = float(raw_input("Enter your numbers.")
numbers_list.append(new_number)
if math == "+":
print sum(new_number)
if math == "*":
import numpy
product = numpy.product(numbers_list)
print (product)
Close the brackets that was not closed
And properly indent the code
math = raw_input("Addition + or multiplication *.")
numbers = int(raw_input("How many numbers would you like to use?"))
numbers_list = []
for input in range(numbers):
new_number = float(raw_input("Enter your numbers."))
numbers_list.append(new_number)
if math == "+":
print sum(new_number) # throws error TypeError: 'float' object is not iterable, so it should be
#print sum(numbers_list)
if math == "*":
import numpy
product = numpy.product(numbers_list)
print (product)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.