Advertisement
here2share

# list_fixed_shuffle.py

May 8th, 2015
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. # list_fixed_shuffle.py
  2.  
  3. import random
  4.  
  5. items = ['a', 1, 'b', 'c', 2, 3, 'd', 'e', 'f', 4]
  6. fixed = sorted([1,4,5,9])
  7. trade = items[:]
  8. def fixed_shuffle():
  9.     for fix in fixed:
  10.         trade[fix] = ''
  11.     while '' in trade:
  12.         trade.remove('')
  13.     random.shuffle(trade)
  14.     for fix in range(len(items)):
  15.         if fix in fixed:
  16.             trade.insert(fix,items[fix])
  17.     return trade
  18. #
  19.  
  20. for demo in range(10):
  21.     print fixed_shuffle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement