所以,如果我有:
lower = int(input("Enter the lower limit: "))
upper = int(input("Enter the upper limit: "))
如何打印下限(含)和上限(含)以及每个方块之间的每个数字?
例如:
用户输入:
Enter the lower limit: 1
Enter the upper limit: 5
预期产出
Numbers: 1,2,3,4,5
Squares: 1,4,9,16,25
答案 0 :(得分:0)
只是做:
lower = int(input("Enter the lower limit: "))
upper = int(input("Enter the upper limit: "))
List = (range(lower, upper + 1))
squared = [x ** 2 for x in List]
print "Numbers: " + ",".join(str(x) for x in List)
print "Squares: " + ",".join(str(x)for x in squared)