0

次のことを達成するには、Python ドキュメントのどの領域を調べる必要がありますか。

npc_gender = ["Male","Female"]
npc_age = # trying to do random integer within a range say 18-80
npc_name_male = ["Arnold","Bob","Charles","David","Edward"]
npc_name_female = ["Annie","Barbara","Courtney","Danielle","Ellen"]
""" Obviously, the names are gender specific for an if/else statement :) """
npc_weight = # trying to figure out how to do range...not sure yet, but still variable.
npc_height = # same a weight...not sure yet.

def create_npc():
    if npc_gender == "Male"
        # select (automatically) one of the npc_name_male[#:] and store.
        return npc_name_male[#:]
    elif npc_gender == "Female"
        # select (automatically) one of the npc_name_female[#:] and store.
    else:
        return

今、私は混乱しています...基本的に、変数に既に保存されているパラメーターの選択からプログラムにキャラクターを作成してもらいたいのです...

私は正しい方向に向かっていますか?前もって感謝します。

ブレンダーへの応答:

import random
npc_gender = ["Male","Female"]

def create_npc():
    npc_gender_choice = random.choice(npc_gender)
    print(npc_gender_choice)

create_npc()

私はこれを行い、理解するのに役立ちました。すべてが機能するまで作業を続けてから、投稿を更新します。ありがとう!

4

1 に答える 1