محتاج مساعدة “مشروع الارنب"

كيف يمكنني حذف العنصر رقم 2-3 من السطر الأول؟

line_1= [“:herb:” ,“:herb:”, “:herb:”]

5 إعجابات

3 إعجابات

line_1.remove(1,"🌿")
    print(line_1)



ine_1.remove(1,"🌿")
    ~~~~~~~~~~~~~^^^^^^^^
TypeError: list.remove() takes exactly one argument (2 given)

3 إعجابات

المفروض تعطى remove شيء واحد وليس شيئين

3 إعجابات

هذا كود المشروع، أنا لم أرَ الحل بعد الكود يعمل، لكن أعتقد أنه أطول بكثير.





```print("welcome to place the rabbit 🐰. ")

line_1=   ["🌿","🌿","🌿"] 
line_2=   ["🌿","🌿","🌿"] 
line_3=   ["🌿","🌿","🌿"]

print(line_1)
print(line_2)
print(line_3)
print("Where should the rabbit go 🐇?")
choice=  input("Please chose a row and a column:")
#=============================================
if choice == "11":
     line_1.insert(0,"🐇")
     line_1.remove("🌿")
     print(line_1)
     print(line_2)
     print(line_3)
elif choice == "12":
    line_1.insert(1,"🐇")
    #line_1.remove ()
    print(line_1)
    print(line_2)
    print(line_3)
elif choice == "13":
     line_1.append("🐇")
     line_1.remove ("🌿")
     print(line_1)
     print(line_2)
     print(line_3)
elif choice == "21":
     line_2.insert(0,"🐇")
     line_2.remove("🌿")
     print(line_1)
     print(line_2)
     print(line_3)
elif choice== "22" :
     line_2.insert(1,"🐇")
     
     line_2.remove,("2")
     print(line_1)
     print(line_2)
     print(line_3)
elif choice == "23":
     line_2.append("🐇")
     line_2.remove("🌿")
     print(line_1)
     print(line_2)
     print(line_3)
elif choice== "31":
     
     line_3.insert(0,"🐇")
     line_3.remove("🌿")
     print(line_1)
     print(line_2)
     print(line_3)
elif choice == "32":
     line_3.insert(1,"🐇")
     print(line_1)
     print(line_2)
     print(line_3)
elif choice == "33":
     line_3.append("🐇")
     line_3.remove ("🌿")
     print(line_1)
     print(line_2)
     print(line_3)
إعجابَين (2)
المشكلة الثانية هي أنه في كل سطر عندما أكتب الرقم 2 ، يحدث هذا :smiling_face_with_tear:



إعجابَين (2)

عدلت اشياء بسيطه وصار شغال

هذا هو الكود بعد التصحيح :

print("welcome to place the rabbit 🐰. ")

line_1= ["🌿","🌿","🌿"]
line_2= ["🌿","🌿","🌿"]
line_3= ["🌿","🌿","🌿"]

print(line_1)
print(line_2)
print(line_3)
print("Where should the rabbit go 🐇?")
choice= input("Please chose a row and a column:")
#=============================================
if choice == "11":
line_1.remove ("🌿")
line_1.insert(0,"🐇")
print(line_1)
print(line_2)
print(line_3)
elif choice == "12":
line_1.remove ("🌿")
line_1.insert(1,"🐇")
print(line_1)
print(line_2)
print(line_3)
elif choice == "13":
line_1.remove ("🌿")
line_1.append("🐇")
print(line_1)
print(line_2)
print(line_3)
elif choice == "21":
line_2.remove ("🌿")
line_2.insert(0,"🐇")
print(line_1)
print(line_2)
print(line_3)
elif choice== "22" :
line_2.remove ("🌿")
line_2.insert(1,"🐇")
print(line_1)
print(line_2)
print(line_3)
elif choice == "23":
line_2.remove ("🌿")
line_2.append("🐇")
print(line_1)
print(line_2)
print(line_3)
elif choice== "31":
line_3.remove ("🌿")
line_3.insert(0,"🐇")
print(line_1)
print(line_2)
print(line_3)
elif choice == "32":
line_3.remove ("🌿")
line_3.insert(1,"🐇")
print(line_1)
print(line_2)
print(line_3)
elif choice == "33":
line_3.remove ("🌿")
line_3.append("🐇")
print(line_1)
print(line_2)
print(line_3)

في الاثنين، ٦ يناير، ٢٠٢٥ ١٢:١٥ م Otman عبر أكتو كود تعلم البرمجة من الصفر <notifications@octucode1.discoursemail.com> كتب:

3 إعجابات

آه، فهمت أنه يجب أن أضع remove قبل insert. أنت معلم، شكرًا. :grin::smile:

3 إعجابات

عـفـوا اخـي الـكريـم :innocent: :blush:

إعجابَين (2)

ها هو المشروع =»

**area=[[“:herb:”,“:herb:”,“:herb:”],
[“:herb:”,“:herb:”,“:herb:”],
[“:herb:”,“:herb:”,“:herb:”]]

ans=input(f"{area[0]}\n {area[1]} \n {area[2]}\n Write place the rabbit :rabbit2: \n Put height and width. ")
ans1=int(len(ans))

if ans1==2:
area[int(ans[0])-1]. remove (“:herb:”)
area[int(ans[0])-1].insert(int(ans[1])-1,“:rabbit2:”)
print(f"{area[0]}\n{area[1]}\n{area[2]}")
else:
print(“Put the two places just.”)**

4 إعجابات

جميل وهذا نفس الكود ولاكن بطريقه منظمه حتى يسهل نسخه :

area=[["🌿","🌿","🌿"],
["🌿","🌿","🌿"],
["🌿","🌿","🌿"]]

ans=input(f"{area[0]}\n{area[1]}\n {area[2]}\nWrite place the rabbit 🐇 \n Put height and width. ")
ans1=int(len(ans))

if ans1==2:
  area[int(ans[0])-1]. remove ("🌿")
  area[int(ans[0])-1].insert(int(ans[1])-1,"🐇")
  print(f"{area[0]}\n{area[1]}\n{area[2]}")
else:
  print("Put the two places just.")
3 إعجابات

مكنتش عارف أرسله كده الصراحة ،
شكرًا .

3 إعجابات

العفو


لإرسال الكود بهذه الطريقه :

النتيجه :

print ("hello ,world ")
4 إعجابات

هههه إنصدمت من الحل ههههه انا عامل الكود من 70 سطر والمستر 10 سطور فقط :flushed::sweat_smile::sweat_smile:

إعجابَين (2)

ههه ، عادى في المشاريع الصغيره ولاكن في المشاريع الكبيره لازم تحاول تقلل عدد السطور عشان تقلل مساحه التخزين للعبه وتقلل الجليتشات، والمهم حاليا انك عرفت توصل للحل

3 إعجابات

كويس انك حاولت وطلعت بحل, انا مكنتش عارف احله ازاي اصلا هههههه

3 إعجابات

شكراااا على كلامك المشجع :smile::smile:

إعجاب واحد (1)
print("Welcome to the place Rabbit.")
area=[   ["🌿","🌿","🌿"],["🌿","🌿","🌿"],["🌿","🌿","🌿"]   ]
print    (f"{area[0]}\n{area[1]} \n{area[2]}  \n{"where should the rabbit go?🐇"} ")
all= (input("please chose hight and length :"))
hight= int(all[0])
length= int (all[1])
area [hight-1][length-1] = "🐇"
print(f"{area[0]}\n {area[1]}\n {area[2]}")
إعجابَين (2)