Jump to content

help / python


Recommended Posts

import random
Students = { }
class ID_SYSTEM:
    Used_Ids = [ ]
    def generate_new_id ( ):
        id = random.randint ( 1900000 , 1999999 )
        if id in Used_Ids:
            generate_new_id ( )
        else:
            return id
    def remove_id ( id ):
        if id in Used_Ids:
            list.remove ( id )
    def count_id ( ):
        count = 0
        for _ in Used_Ids:
            count += 1
        return count
        
def Add_New ( to_be_added )
    to_be_added = str ( to_be_added)
    last_index = -1
    for x in Students:
        last_index += 1
    Students[last_index] = [ ID_SYSTEM.generate_new_id ( ) , to_be_added ]

Add_New ( 'RONTGEN' )

لما استعمل وظيفه  Add_New

كلمه RONTGEN 

ما تنضاف لللائحه

و يقلي خطا في سطر

    Students[last_index] = [ ID_SYSTEM.generate_new_id ( ) , to_be_added ]

انا مااشوف خطا صراحه فاذا احد يقدر يساعد

Edited by #x1AhMeD-09
Link to comment
15 minutes ago, MrBiG said:

شوف اخوي 

https://www.dreamincode.net/forums/forum/29-python/

سجل في هذا الموقع في ناس  محترفين بجميع اللغات ويساعدو ( عددهم كثير) واطرح مشكلتك 

افضل من هنا 

 

مشكور بس خلاص حليتها

المشكله كان في تعريف المتغيرات نسيت احط

global

  • Like 1
Link to comment
  • 2 weeks later...
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...