Programming/Python
[Python] 기초문법 : 리스트에서 랜덤 추출하기
Allen93
2023. 11. 14. 18:06
리스트 자료형에서 random.choice 함수를 쓰면 리스트에서 랜덤하게 하나의 데이터가 출력됩니다.
import random
word = ['apple','banana','kiwi']
choiceList = random.choice(word)
print(choiceList)
728x90