انفذ الكود التالي :
from random import choice
quotes_list=[
"for jnkjs smdlkm psdlkasmd jknalnd klasldks kja;wkkm sdklks kmlkgfgh",
"every knjksd kjsdkj kjhdskhs kjhas kjaskas jk iojoijs jkkhslfgfd ",
"its khsdn sjkdkjlsd kdsnkn skjd kjsda kahsw nashdkj kjashd "
]
def get_quotes():
return"\n".join(quotes_list)
def add_quotes(quotes):
if isinstance(quotes , str): # isinstance(quotes , str) دالة بيلد ان بايثون للتحقق من ان المدخل نص
quotes_list.append(quotes)
else:
return 'the quotes must be a string'
# to select random quote from quotes
# we import choice from random in the top
def get_random_quote():
return choice(quotes_list)
if __name__ == ' __main__':
print(get_random_quote())
add_quotes('you only love me')
print(get_quotes())
و لكن دون ان يظهر لي نتائج بعد اضافة if __name__ == ' __main__':