|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
题目是:
1)Write a program that gets four numbers as input from the user. 2)And then print the largest one, and save the other three numbers in a tuple.
我写的代码是:
t = tuple()
a = input("what are the four numbers that you want to insert")
b = int(a)
c = max(b)
print(c)
remaining = b.remove(c)
t = [remaining]
问题
1)这个代码到底哪一步出问题 2)题目说要将其余三个较小的数字储存在tuple里面, 我这样写对不对。非常感谢
- t = tuple()
- list1 =[]
- for i in range(4):
- list1.append(int(input("请依次输入四个数字:")))
- c = max(list1)
- print("最大的为",c)
- list1.remove(c)
- t = tuple(list1)
- print("其余三个:",t)
复制代码
|
|