这就是我陷入困境,试图用网络课程学习Python的地方。用for-loop将输入分成两部分
编写一个程序,采取以下形式«NUMBER1»的单个输入线+«NUMBER2»,其中这两个代表正整数,并输出两个数的总和。例如在输入5 + 12的输出应为17
我们不应该使用分裂()或任何进口。
我认为解决方案是使用字符和它的值43和那种方式子字符串,但我不知道。我确信唯一的解决方案是简单的没有花哨的功能或进口需要。
以下是我认为可能接近解决
S = input()
for position in range(0,len(S):
#code for substrings 5 to number1, and 12 to number2
result = int(number1)+int(number2)
print(result)
你不能只使用两个raw_input()表达式吗? –
不,他们没有覆盖我们目前阅读的材料。 – Aenohe
相关:[Python - 使用for循环而不是Split方法或任何其他方法提取子字符串](http://stackoverflow.com/questions/18599398/python-extracting-a-substring-using-a-for-loop -this-of-split-method-or-any) –