اين الخطأ
إعجابَين (2)
سلام عليكم ورحمت الله وبركاته
حضرتك نسيت تسدعي مكتبة random و ايضا هناك اخطاء في الكود الخاص بك إليك الكود الخاص بي لتقارن كودك مع كودي و حاول تستكشف الأخطاء كودك و تصليحها و حاول ان تتعلم من الأخطاء
import random
choise = int(input("Welcome to the coin toss game \n1. you have chosen random.randint() \n2. you have chosen random.random()\nEnter your choice 1 oг 2..."))
if choise == 1:
str_random = random.randint(0,1)
if str_random == 1:
computer_guess = "heads"
else:
computer_guess="tails"
elif choise == 2:
str_random = random.random()
if str_random >= 0.5:
computer_guess ="heads"
else:
computer_guess="tails"
else:
print("Invalid choice")
print("Please enter 1 or 2")
User_choose = input("Enter your choice of (Heads) or (Tails): ").lower()
if User_choose == computer_guess:
print("Well done, you won.")
else:
print("Sorry you lost, you can try again")
إعجابَين (2)
انا استدعيت مكتبة random بس انا مصورة من السطر السادس
ممكن تكتبلي وين الخطأ لاني ما لاحظته