Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use random.choice instead of random.randint#9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mjhea0 merged 1 commit intorealpython:masterfromuttamo:patch-1
Sep 29, 2017
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletionsscripts/13_random_name_generator.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
from random importrandint
from random importchoice


def random_name_generator(first, second, x):
Expand All@@ -10,13 +10,8 @@ def random_name_generator(first, second, x):
- number of random names
"""
names = []
for i in range(0, int(x)):
random_first = randint(0, len(first)-1)
random_last = randint(0, len(second)-1)
names.append("{0} {1}".format(
first[random_first],
second[random_last])
)
for i in range(x):
names.append("{0} {1}".format(choice(first), choice(second)))
return set(names)


Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp