1
1

More than 3 years have passed since last update.

pythonで「A と、見せかけて B」と、出力してくるコードを作成する

Last updated at Posted at 2020-04-11

pythonで「A と、見せかけて B」と、出力してくるコードを作成する

目的

pythonで「A と、見せかけて B」と、出力してくるコードを作成した際の備忘録です

準備

pythonのchoiceを使います。

random.choice

コード

import random

l = ["りんご",
     "みかん",
     "いちご",
     "パイナップル",
     "ドラゴンフルーツ"]

string1=random.choice(l)
string2=random.choice(l)

print(string1, " と、見せかけて ", string2)
$ python sample.py
りんご  と、見せかけて  ドラゴンフルーツ

参考

Pythonでリストからランダムに要素を選択する
random.choice

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1