Skip to main content
 首页 » 编程设计

python : function definition keeps returning 'None' in the middle of the desired output

2025年05月04日10Renyi-Fan

<分区>

好吧,我正在为我的女朋友编写我们 6 周年纪念日的代码。 我是编程的完全菜鸟。我正在编写一些非常简单的代码来制作,基本上是一个数字输入的输入输出机器,以便用户(她)接收字符串输出。

当我运行我的代码时,我一直看到“无”。为什么? 开始。

def love(n): 
  if n < 0 :  
    print "Why would it be negative?!"  
  if n == 0 :  
      print "well that is just hurtful"  
  if n == 1 : 
    print "I REALLY love you"  
  if n == 2 :  
    print "You make me smile at least once, each and every day" 
  if n == 3 :  
    print"you wouldn't believe how annoying it was to get this program to run properly! but it was worth it" 
  if n == 4 :  
      print "let's " + "shoot a little higher than that" 
  else: 
    print "I honestly can't see myself without you anymore"  
 
 
print love(0)  
 
print "Wanna try again? :D "