와 내가 파이썬에 새로운 오전과 내가 grok 수와 함께 배우는,하지만 난이 부분에 붙어있어{형식 오류 : 지원되지 않는 피연산자 유형 (들) +에 대한 'INT'와 'STR'} 입력
money = input("Enter the expenses: ")
addup = money.split()
total = sum(addup)
print("Total: ", total)
와 내가 파이썬에 새로운 오전과 내가 grok 수와 함께 배우는,하지만 난이 부분에 붙어있어{형식 오류 : 지원되지 않는 피연산자 유형 (들) +에 대한 'INT'와 'STR'} 입력
money = input("Enter the expenses: ")
addup = money.split()
total = sum(addup)
print("Total: ", total)
입니다
이이 작동하는 것은 :
money=map(float,input().split()) #could have use int as well if input was a sequence of integers
total=sum(money)
print("Total:",total)
또한이 작업을 수행 할 수 있습니다 : 파이썬 입력에서
Total=sum(map(float,input().split())) #could have use int as well if input was a sequence of integers
print("Total:",total)
은 기본 문자열로 촬영 당신은 그것을 형변환해야합니다
int(input("enter the expenses should work: "))
또는 당신이 필요로하는 모든 타입 변환하는 것입니다 또는 일반적으로
float(input("enter the expenses should work: "))
을 떠 경우 귀하의 의견은
map(int,input().split()) #can use float here as well
파이썬 2.x를지도에서 생성됩니다 않는 번호의 목록 인 경우 목록 및 파이썬 3.x에서 생성기를 생성합니다.
만약 그들이 떠 다니면 어떨까요? – SuperStew
나는 의도 한 입력이'12 34 56 78' 같은 것임을 의심한다. –
@SuperStew 네, 게시물을 편집했습니다. – Demonking28
정확히 무엇을 고집하고 있습니까? – glibdud
예 .. 오류가 발생하는 줄 번호가 필요합니다 - sum() 함수입니까? 정수에 문자열을 추가하려고합니까? –
@ 오스카 나는 당신의 문제에 따라 나의 대답을 편집했다. 나는 당신이 대답을 도움이되는 것을 정확한 답으로 생각한다. :) – Demonking28