我的代码:“引用赋值之前”错误条件语句
def sandwich(str, meat = 'ham', cheese = 'American'):
if sandwich(str, meat = None, cheese = None):
sandwich = str +' bread sandwich with turkey '
else:
sandwich = str +' bread sandwich with ' + meat + ' and '+ cheese + ' cheese'
return sandwich
我用一个定义参数尝试。这没有用。它给了我一个错误:
The local variable(sandwich) is being referenced before the assignment.
请帮助!
请粘贴问题的代码在这里,而不是在一些外部链接。 – Mureinik
三明治(str,meat ='ham',cheese ='American'): 全球三明治 if sandwich(str,meat = None,cheese = None): sandwich = str +'bread sandwich sandwich with turkey' else : sandwich = str +'面包三明治'+肉+'和'+奶酪+'奶酪' 返回三明治 –
它也在描述中。链接是为了这个问题。 –