擅长:python、mysql、java
<p>如果你问为什么不给<code>user_choice</code>一个<code>None</code>的值,那是因为你从来没有定义过<code>user_choice</code>如果那些If语句都不是真的</p>
<p>您希望您的代码更像这样。您的代码中有多个错误,我已全部修复</p>
<pre><code>def user_input():
user_choice = "" # Defined user_choice before taking the input
x = input("Choose :Charizard, Blastoise, or Venusaur: ")
if "char" in x:
user_choice = "Charizard"
elif "blast" in x:
user_choice = "Blastoise"
elif "ven" in x:
user_choice = "Venusaur"
return user_choice
print(user_input()) # This prints the value of the object returned by the function
</code></pre>