qq_52709669
qq_52709669
采纳率0%
2021-03-08 22:16

新手求救!!python 中的if-elif一直运行不了...

#抽签测运势

import random

print("Let's test your today luck!")

lot=random.randint(1,4)

if lot==1:
        #上上签
​	print("the best lot!!","\n\nwow!You're the most lucky people who I have seen!!!")

elif lot==2:
        #上签
​	print("better lot!","\n\nFantastic!")

elif lot==3:
        #中签
​	print("so-so lot","\n\nnot bad~")

elif lot==4:
        #下签
​	print("a little bad","\n\nDon't worry!It represents just now!")

else:
        print("??")

input("\n\nPress the enter key to exit.")

求大佬救救自学的可怜孩子5555

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • funny123 coagenth 1月前
    import random
    
    print("Let's test your today luck!")
    
    lot = random.randint(1, 4)
    print(f"Today You've number {lot}")
    if lot == 1:
        #上上签
        print("the best lot!!", "\n\nwow!You're the most lucky people who I have seen!!!")
    
    elif lot == 2:
        #上签
        print("better lot!", "\n\nFantastic!")
    
    elif lot == 3:
        #中签
        print("so-so lot", "\n\nnot bad~")
    
    elif lot == 4:
        #下签
        print("a little bad", "\n\nDon't worry!It represents just now!")
    
    else:
        print("??")
    
    input("\n\nPress the enter key to exit.")

    你的代码缩进有问题。复制这段代码就可运行了

    点赞 1 评论 复制链接分享
  • weixin_44416114 异城一人 1月前

    如果用pycharm应该会报错,缩进

    点赞 评论 复制链接分享

为你推荐