list tag

251 questions


1 answers
42 views
0
Error trying to put Python strings in the list one by one. TypeError: string indices must be integers, not str

I'm trying to cut strings one by one and put them on the list, but I keep getting errors. I'd appreciate it if you could tell me what the problem is.string = Hello World!list = []for i in string: lis...

2 years ago

1 answers
103 views
0
Differences between Python lists and sets

If you try to find the same value among the two lists in Python, it is usually for i in list1: for j in list2: if i == j : print(i)I found it using the for statement twice, but I changed it to a set...

2 years ago

1 answers
35 views
0
Sort Python List

For example, ['level 10', 'level 4', 'level8', 'level9']level 10level 9level 8level 4I want to print it out like this, but if you just use a sort,level 9level 8level 4level 10This is what happens.Do y...

2 years ago

1 answers
36 views
0
I want to compare the items in the same index from the two lists and output only the common elements.

I want to input two lists and compare each list at the end and print out only the common item '0', what should I do? For example, when you enter it in the shell window,Enter cammate 1's Monday timetab...

2 years ago

1 answers
59 views
0
Python map function question..

I learned in Python that the map function is saved as a list.If so, I want to print out elements from the list created by the map function, but I get an error.Is there any other way I don't know?num, ...

2 years ago

1 answers
35 views
0
Python two-dimensional list, putting 5050 data into a triangle shape

If list1 has 5050 data from 1 to 5050, I'd like to convert it into a two-dimensional list.Put 1 in (0,0) and (1,0) = 2, (1,1) = 2, (2,0) = 4, (2,1) = 5

2 years ago

1 answers
40 views
0
To simplify functions of the same pattern defined by button_1_callback, ..., buttono_8_callback

Is there any way to reduce the coding using the list function in the coding below?If it is not, or inefficient, could you tell me how to use another function?import RPi.Bringing up GPIO as GPIO #GPIO ...

2 years ago

1 answers
74 views
0
Find max value in Python 2D list

list_1 = [(2, 0), (1, 1), (3, 2), (2, 3)]temp = list_1[0][0]if temp < max(list_1):I want to make sure that the values from the two-dimensional list are the highest values in this listSince it is a ...

2 years ago

2 answers
105 views
0
Draw a graph of gravity according to altitude with matplotlib

N = 80z = np.zeros((N,2))for h in range(0,80,1): z[h,0] = h #constants mass_earth = 5.9722*10**(24) #[kg] radius_earth = 6371*10**(3) #[m] universal_gravitational_const = 6.674*10**(-11) #[m^3/kg^-1*s...

2 years ago

1 answers
42 views
0
Python: Curious about making lists with dynamic variables.

Hello, this is Corinne. I want to implement one, but it doesn't work.What I want to implement is So the final goal is to split an arbitrary list into the number you enter, and to bind an automatically...

2 years ago
« - 20 - »

© 2024 OneMinuteCode. All rights reserved.