مثال توضیح داده شد(Example Explained)

یک تابع ایجاد کنید که یک لیست را به عنوان آرگومان دریافت کند.




Create a Function



def my_function(x):

  return list(dict.fromkeys(x))

mylist =
my_function(["a", "b", "a", "c", "c"])


print(mylist)




با استفاده از این موارد فهرست به عنوان کلید، یک فرهنگ لغت ایجاد کنید.



Create a Dictionary



def my_function(x):

  return list(
dict.fromkeys(x))

mylist =
my_function(["a", "b", "a", "c", "c"])


print(mylist)




فرهنگ لغت را به لیست تبدیل کنید.



Convert Into a List



def my_function(x):

  return
list(dict.fromkeys(x))

mylist =
my_function(["a", "b", "a", "c", "c"])


print(mylist)




لیست را برگردانید



Retu
List



def my_function(x):

 
return list(dict.fromkeys(x))

mylist =
my_function(["a", "b", "a", "c", "c"])


print(mylist)




با یک لیست به عنوان پارامتر، تابع را فراخوانی کنید:




Call the Function



def my_function(x):

  return list(dict.fromkeys(x))


mylist = my_function(["a", "b", "a", "c", "c"])


print(mylist)



نتیجه را چاپ کنید:




Print the Result



def my_function(x):

  return list(dict.fromkeys(x))


mylist = my_function(["a", "b", "a", "c", "c"])


print(mylist)