Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #تفكيك المتغيرات الي تسلسلات مختلفة
- s=[1,2,3]
- a,b,c=s #هنا تحصل عملية تفكيك بحيث اي عنصر هياخذ قيمه معينه
- print(a)
- print(b)
- print(c)
- g="abobaker"
- a,b,c,d,e,f,k,h=g
- print(a)
- print(b)
- print(c)
- print(d)
- print(e)
- print(f)
- print(k)
- print(h)
- k=["beko","hlal","mohaemd"]
- g,h,j=k
- print(g)
- print(h)
- print(j)
- #مثال اخر
- y=(7,8,6,5,4)
- a,b,*c=y #يستخدم الموشر * لكي يدل علي ان المتغير يمكنه ان يخزن عدة قيم
- print(a)
- print(b)
- print(c)
- print("____________________________________")
- ########################
- records = [
- ('foo', 1, 2),
- ('bar', 'hello'),
- ('foo', 3, 4),
- ]
- def do_foo(x, y):
- print('foo', x, y)
- def do_bar(s):
- print('bar', s)
- for tag, *args in records:
- if tag == 'foo':
- do_foo(*args)
- elif tag == 'bar':
- do_bar(*args)
Advertisement
Add Comment
Please, Sign In to add comment