我正在尝试编写一些代码来接受三个变量用户输入,并且如果用户只使用if语句输入一个,两个或全部三个,则执行不同的操作。 我似乎无法做到正确,我似乎没有正确地将第三个变量传递给需要它的方法。 我想知道是否有人可以告诉我我做错了什么?
def test_codes(self):
codestring = input("Enter a functioning codestring: ")
wildcard = input("Enter the wildcard string for the codestring, or press enter to ignore: ")
phone_num = input("Enter the phone_num phone number of your choice, or press enter to ignore: ")
if codestring:
self.testscode.makecall(codestring)
if codestring and wildcard:
phone_num = "1234457890"
self.testscode.makecall(codestring, wildcard, phone_num)
if codestring and wildcard and phone_num:
if phone_num:
self.testscode.makecall(codestring, wildcard, phone_num)
else:
phone_num = "1234457890"
self.testscode.makecall(codestring, wildcard, phone_num)