Create code that outputs "A and pretending B" in python

Create code that outputs "A and pretending B" in python

Purpose

It is a memorandum when I created the code that outputs "A and pretending to be B" in python.

Preparation

Use python's choice.

random.choice

code

import random

l = ["Apple",
     "Mandarin orange",
     "Strawberry",
     "pineapple",
     "Dragon fruit"]

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

print(string1, "Pretending to be", string2)
$ python sample.py
Apples and dragon fruit pretending to be

reference

Randomly select an element from a list in Python random.choice

Recommended Posts

Create code that outputs "A and pretending B" in python
Let's create a customer database that automatically issues a QR code in Python
Create a dictionary in Python
In Python, create a decorator that dynamically accepts arguments Create a decorator
Python a + = b and a = a + b are different
Create a DI Container in Python
Let's create a script that registers with Ideone.com in Python.
Create a binary file in Python
Create a Kubernetes Operator in Python
[Python] return A [or / and] B
Create a random string in Python
Create and read messagepacks in Python
Create a Python environment for professionals in VS Code on Windows
[Python / Django] Create a web API that responds in JSON format
Create a CGH for branching a laser in Python (laser and SLM required)
Create a simple Python development environment with VS Code and Docker
Solve ABC175 A, B, C in Python
Create a simple GUI app in Python
Create a JSON object mapper in Python
Solve ABC165 A, B, D in Python
[Python] Create a LineBot that runs regularly
[GPS] Create a kml file in Python
I tried to develop a Formatter that outputs Python logs in JSON
Code reading of faker, a library that generates test data in Python
One liner that outputs multiplication tables in Python
Create a Vim + Python test environment in 1 minute
Organize python modules and packages in a mess
Create a GIF file using Pillow in Python
A memo that I wrote a quicksort in Python
I want to create a window in Python
Create a standard normal distribution graph in Python
How to create a JSON file in Python
Automatically create word and excel reports in python
I wrote a class in Python3 and Java
Create a virtual environment with conda in Python
Create a page that loads infinitely with python
A program that removes duplicate statements in Python
Create a simple momentum investment model in Python
Python: Create a class that supports unpacked assignment
python memo-"if not A and B" was "if (not A) and B"
Create a new page in confluence with Python
Create a datetime object from a string in Python (Python 3.3)
Create a package containing global commands in Python
Create a Mac app using py2app and Python3! !!
Create a MIDI file in Python using pretty_midi
Create a loop antenna pattern in Python in KiCad
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Create a Python development environment in 10 minutes (Mac OS X + Visual Studio Code)
Create a Python image in Django without a dummy image file and test the image upload
I tried to create a class that can easily serialize Json in Python
Create a plugin that allows you to search Sublime Text 3 tabs in Python
I want to create a priority queue that can be updated in Python (2.7)
Create a Django project and application in a Python virtual environment and start the server
Create a Python module
Create SpatiaLite in Python
Create a Python environment
Python3> round (a --b, 7)
Create a data collection bot in Python using Selenium
[LINE Messaging API] Create a rich menu in Python
A collection of code often used in personal Python
Let's write python code that parses go code and generates go code