About list processing (Python beginners after learning Ruby)

List processing

Partial supplement to list processing

list.py


#split function Splits the given data with the specified arguments and returns it as a list. I will not use it this time.

#random.randrange function Randomly retrieves from the elements of the list of arguments

import sys
import random
dice = []
for line in sys.stdin.readlines():
    dice.append(line.rstrip())

#Value to be entered(Example)
1
2
3
4
5
6
#The numbers from 1 to 6 entered for each line are stored in the list of dice variables

num = len(dice)

print(dice[random.randrange(num))

#Any of the 0th 1 to 5th 6 of the contents of the dice is output.

Processing supplement for input

line = input (). rstrip () #rstrip function Look into the line feed code at the end of the character string.

import sys line = sys.stdin.readlines () # sys.stdin.readlines function file-Reads all input values ​​on multiple lines and processes them line by line.

Recommended Posts

About list processing (Python beginners after learning Ruby)
About adding / deleting lists (Python beginners after learning Ruby)
Learning flow for Python beginners
About python beginner's memorandum function
About Perl, Python, PHP, Ruby
Python #list for super beginners
Machine learning summary by Python beginners
<For beginners> python library <For machine learning>
About the basics list of Python basics
Memorandum of python beginners About inclusion notation
python learning
[Python] list
About data expansion processing for deep learning
I investigated in detail about variable processing in python
# 1 Python beginners make simple English word learning tools
Python vs Ruby "Deep Learning from scratch" Summary
About shallow and deep copies of Python / Ruby
About Python List Index (Paiza POH Lite 4: Mission 3)
About Python external module import <For super beginners>
About python slices
About python comprehension
Python basics: list
[Python] Learning Note 1
python image processing
About Python tqdm.
About python yield
About python, class
python learning output
Python file processing
About python inheritance
Python learning day 4
About python, range ()
Python Deep Learning
About python decorators
Python learning (supplement)
Python> Comprehension / Comprehension> List comprehension
Deep learning × Python
Beginners practice Python
[Python] About multi-process
Python beginner's note
python learning notes
Python list manipulation
What I learned about AI / machine learning using Python (1)
Perform C # processing after executing Python processing asynchronously in Unity
Python beginners talk about how to remember this much
Nothing remains after making a python map object a list
What I learned about AI / machine learning using Python (3)
What I learned about AI / machine learning using Python (2)