-4
error: Can't convert int to str implicitely
user_name = input("What is your name? ")
print("Hello {}!, this program is going to ask you to type in a series of numbers (all positive integers)" .format(user_name))
total_numbers = input("How many numbers would you like to add")
for i in range(1, total_numbers):
number = float(input("State a numbers {}: " .format(i)))
total_numbers += number
print("Total number: {}" .format(total_numbers))
我的任務是:詢問用戶名輸入。它應該存儲在一個合適的變量中(如user_name
) 詢問將輸入多少個數字。將其存儲在適當的變量中。 (如「num_values
」) 然後獲取輸入的每個數字。 你需要有保持總全都在結尾處的數字和一些辦法,一旦所有的數字已輸入,你需要打印出像..
現在它來了類型錯誤:「你叫什麼名字」:無法轉換浮到隱含str的 這是目前的代碼USER_NAME =輸入( ) print(「Hello {} !,這個程序會要求你輸入一系列數字(所有正整數)」.format(user_name)) total_numbers = input(「你想要多少個數字添加「) 我在範圍內(1,int(total_numbers)): number = float(input(」State a numbers {}「.format (i))) total_numbers + = number print(「Total number:{}」.format(total_numbers)) – Sophie321