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

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




Create a Function



def my_function(x):

  return x[::-1]

mytxt =
my_function("I wonder how this text looks like backwards")


print(mytxt)




رشته را که از انتهای رشته شروع می شود برش دهید و به سمت عقب حرکت کنید.



Slice the String



def my_function(x):

  return x
[::-1]

mytxt =
my_function("I wonder how this text looks like backwards")


print(mytxt)




رشته رو به عقب را برگردانید



Retu
the String



def my_function(x):

 
return
x[::-1]


mytxt =
my_function("I wonder how this text looks like backwards")


print(mytxt )




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




Call the Function



def my_function(x):

  return
x[::-1]


mytxt = my_function("I
wonder how this text looks like backwards")


print(mytxt)



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




Print the Result



def my_function(x):

  return
x[::-1]


mytxt = my_function("I wonder how this text looks like backwards")


print(mytxt)