Python使用for循环,计算1-n的和,其中n有用户动态输入。n=?(input(“请输入一个数字:”))sum1=0for i in range(n): sum1+=i print(“1-% s的和:”%n,sum1)
请问n应该用什么类型,一定是整数类型吗?
int或者eval