I'm a beginner at Python. Let me ask you how to use random functions

Asked 1 years ago, Updated 1 years ago, 106 views

Hello. I'm currently studying Python introductory course.

I want to leave a question about the random function.

import random
count = 2
paper_list =  [ ]
paper_list.append("A")
paper_list.append ("me")
paper_list.append("Da")
paper_list.append("ra")
paper_list.append ("ma")
paper_list.append("bar")
paper_list.append ("company")
paper_list.append("Ah")
paper_list.append ("characters")
paper_list.append ("tea")
paper_list.append("car")
paper_list.append ("other")
paper_list.append("par")
paper_list.append("lower")

print ("primary output = ", random.sample(paper_list, count)))")

It's a function that outputs two strings from the list For the second output, except for the first output In addition, you want to exclude the first and second outputs from the third output.

What should I use at times like this. Should I use the remover from the list and put it in the list one by one, and if I put it in, how should I receive and remove the result from the first output?

If there is a better way, please. It's hard to teach myself ㅠ<

random python

2022-09-22 18:00

1 Answers

In almost all languages, pop is a method of making a list of elements in a particular location - essentially the one at the very end - and then returning that element. Therefore, listz used in the secondary output does not have the two elements used in the primary output, and you can achieve what you want.

I don't know if it's explained.


2022-09-22 18:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.