Splitting input into two with for-loop

前端 未结 2 1043
故里飘歌
故里飘歌 2021-01-25 16:45

This is where I got stuck, trying to learn Python using web-course.

Write a program that takes a single input line of the form «number1»+

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-25 17:30

    Answer

    S = input()
    for position in range(0, len(S)):
    plus=S[position]
        if (plus!="+"):
          continue
        number1=int(S[0:position])
        number2=int(S[position+1:len(S)])
        print(number1+number2)
    

提交回复
热议问题