我的代碼:「引用賦值之前」錯誤條件語句
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 +'麪包三明治'+肉+'和'+奶酪+'奶酪' 返回三明治 –
它也在描述中。鏈接是爲了這個問題。 –