#e.计算列表长度,并输出.
def a(*List):
b = []
for value in List:
b.append(value)
print (len(b))#长度
print (b)#输出列表
#三元操作符,用一条语句完成多个条件判断和赋值操作
x = 4
y = 5
small = x if x < y else y
print(small)
本文介绍了一个简单的Python函数,用于计算输入列表的长度并打印出来。此外,还展示了如何使用Python中的三元操作符来进行条件判断和赋值操作。
#e.计算列表长度,并输出.
def a(*List):
b = []
for value in List:
b.append(value)
print (len(b))#长度
print (b)#输出列表
#三元操作符,用一条语句完成多个条件判断和赋值操作
x = 4
y = 5
small = x if x < y else y
print(small)
被折叠的 条评论
为什么被折叠?