>>> l = ['12', '3', '4']
>>> def mul(num1, num2):
if num1 in l and num2 in l:
return str(int(num1)*int(num2))
else:
return 'Number you specified is not present in the list. Please try again'
>>> print(mul(input('Print the num1 : '), input('Print the num2')))
Print the num1 : 1
Print the num2 : 7
Number you specified is not present in the list. Please try again
>>> print(mul(input('Print the num1 : '), input('Print the num2 : ')))
Print the num1 : 3
Print the num2 : 12
36
您可以通过调用整数在列表中的位置来使用它们。下面是一个加、减和求列表总和的示例:
好像你想要这样的东西
相关问题 更多 >
编程相关推荐