After reading you code and explanation I still have no clue what you want to accomplish ("For column indices , I make a list by randomly generated data and in those indices I want to assign a random value between 5 and 10. For the other values , which hold in rassal list , I want to assign 5")
I just take first 9 lines of code and reduce it to three for better understanding:
If you take a moment and think then you can get same result with one line:
So please take your time and think little about your problem and then formulate **what** you want to do. After that think **how** could you do it. When writing code try to keep **what** and **how** separate otherwise you will end up with code known under 'spaghetti' moniker - hard to read, understand and debug.
I just take first 9 lines of code and reduce it to three for better understanding:
tum = list(range(400)) rassal = random.sample(range(400), 200) new_list = [x for x in tum if (x not in rassal)]So you have list of integers 0...399 (tum). Then you take sample from same range (unique numbers as random sample returns unique random elements and range have unique integers) as rassal. And finally you create new_list from numbers which are not in rassal (random sample). This effectively means that you have 200 random unique numbers in new_list.
If you take a moment and think then you can get same result with one line:
new_list = random.sample(range(400), 200) # get 200 random numbers from range(400)
So please take your time and think little about your problem and then formulate **what** you want to do. After that think **how** could you do it. When writing code try to keep **what** and **how** separate otherwise you will end up with code known under 'spaghetti' moniker - hard to read, understand and debug.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.