Please write your question in detail here.
Write a code in which the numbers "0", "1", and "2" are repeatedly output 2020 times in the order of 0 → 1 → 0 → 2 (→ 0 → 1 →…). I'm stumbling upon solving the example.
Corresponding source code
Cannot repeat processing with the specified number. Please professor.
sample_list = ["'0', '1', '0', '2'"]
for i in sample_list:
Since the challenge is to repeat the specified numbers 2020 times, I decided to list the specified numbers. After that, as far as I know, I tried to solve it by using range to repeat, but it will be repeated with a number other than the specified number.Supplementary information (FW/tool version, etc.)
Please provide more detailed information here.
Answer # 1
for i in range (2020):So, it will loop 2020 times, so you can write the numbers in the list in order.
If you don't know that, you can run your code 505 times, 2020 ÷ 4 = 505.
for j in range (2020 // 4):
Answer # 2
Since only the answer using the for statement and range is given, I will write a program with a slightly different coat color.
It may not be what you originally intended for the question, but keep in mind that there are some of these.
>>>repeat = 4 >>>print ('0 1 0 2'* 4) 0 1 0 2 0 1 0 2 0 1 0 2 0 1 0 2
Replace the first line of this program with repeat = 2020.
Answer # 3
IN and OUT are not clear, but the expected code is
sample_list = [0, 1, 0, 2] for _ in range (2020): print (* sample_list, end ='') print ()
src = input ('3 digit number input>') # 012 lst = src [0: 2] + src [0 :: 2] # 0102 for _ in range (2020): print (* lst, end ='') print ()
Does that mean?
Answer # 4
I don't know what I want to do, but
for i in range (2020): What (0) What (i + 1)
I wonder if that mean
- about processing to exclude the character string group specified from list in python
- python 3x - i'm not sure about asynchronous processing (asyncio)
- python - about multiple processing and loop processing in discordpy
- python - please tell me about the processing contents of opencv background subtraction
- python iterative processing num is not defend
- python - about deleting the specified element of the array the element numbers will shift
- python - about "" "of" "" select === = "" "
- python 3x - about functions used in python for statement
- about image output of python
- python 3x - please teach about the exchange of information with qthead
- python 3x - processing to jump to the link destination using chrome driver in python
- python - about x-axis adjustment in matplotlib
- python - about downloading youtube videos by youtube-dl
- python, about the fire spread step of forest fire simulation
- about iterative processing (for statement, while statement) -about an array that gradually becomes shorter
- python - about the optimum angle of rotation matrix
- python - i want to change the csv file name every time i loop with the for in syntax and save it in the specified folder
- python - tkinter parallel processing
- python - about hamiltonian neural networks
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to call a child component method from a parent in vuejs
- i want to check the type of a shell script variable