random + 리스트 method

Roel·2022년 1월 6일
0

udemy python

목록 보기
3/5

첫번째 방법

# Split string method
names_string = input("Give me everybody's names, separated by a comma. ")
names = names_string.split(", ")

import random

random_int = random.randint(0, len(names)-1)

person = names[random_int]

print(person  + " is going to buy the meal today!")

두번째 방법

import random

person = random.choice(names)


print(person  + " is going to buy the meal today!")
profile
jhyunny

0개의 댓글