اذهب إلى المحتوى

أمير أحمد لطيف هاشم

الأعضاء
  • المساهمات

    5
  • تاريخ الانضمام

  • تاريخ آخر زيارة

كل منشورات العضو أمير أحمد لطيف هاشم

  1. اريد اذا كتب المستخدم اي شي غير اللون تظهر الة ال else ولاتظهرلة بعدها سطر ال input ويطلب لون ثاني شكراً شهاب
  2. بغض النظر عن المسافات البادىة اذا اجاب المستخدم اجابة عشواىية بدل اللون الاول راح تتفعل ال else بس بعدهة راح تظهر ال input ويطلب لون ثاني شنو الحل هنا وشكراً colors = [] colors_0 = input("add the first color you like: \n") colors.append(colors_0) colors_1 = input("Do you want to add more colors? yes or no? \n").lower() if colors_1 == 'yes': far_color = input("add another color to the list:"). colors.append(far_color) print(f"the colors you like are: {colors}") :else print(f"the color you like is: {colors}")
  3. else اكوو خطا تحديدا ب colors = [] colors_0 = input("add the first color you like: \n") colors.append(colors_0) colors_1 = input("Do you want to add more colors? yes or no? \n").lower() if colors_1 == 'yes': far_color = input("add another color to the list:") colors.append(far_color) print(f"the colors you like are: {colors}") else: print(f"the color you like is: {colors}")
  4. import random print("""Welcome to the Coin Guessing Game! \nchoose a method to toss the Coin: \n 1. Using random.random() \n 2.Using random.randint() \n""") num = int(input("enter 1 or 2: \n")) if num == 1: if random.random() >= 0.5: computer_result = "heads" else: computer_result = "tails" elif num == 2: if random.randint(0,1) == 0: computer_result = "heads" else: computer_result = "tails" else: print("Invalid choice. please select either 1 or 2,") exit() user_num = input("enter your guess(heads or tails):") if user_num.lower() == computer_result.lower(): print("congratulations! you win") else: print("sorry, you lost!") print(f"the computer's coin toss result was: {computer_result}") اذا دخل المستخدم احرف او رموز بدل الارقام يحصل خطا كيف اصحح ال ايرورر هذا ؟
×
×
  • أضف...