samyyc.dev
LOC::Macau, China

..UTC+8

samyyc.dev

-- BPM

Tue Mar 12 2024

Note / A Simple Number Guessing Game (Python)

#97

/

samyyc

/

48 words

/

Updated 997 days ago

/

[中文]

Note / A Simple Number Guessing Game (Python)

For a problem like "draw 4 non-repeating digits", the usual approach is to pick an index and then delete it. But Python's random library clearly has a better answer: random.sample, then stitch the digits together with str.join.

import random