Posts by Allan • 413 points
16 posts
-
7
votes3
answers14487
viewsQ: Divide a list into n sublists
I have the following list: l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] What I need is to divide this list into n sublists, in this case it is not possible to do it manually because the n…
-
8
votes1
answer4275
viewsQ: Login to facebook com python
I would like, for educational reason, to login to facebook with a python script. I tried with lib requests import requests s = requests.Session() post_url =…
-
5
votes1
answer479
viewsQ: split a string of n into n chars, split() of n n
I have the following text: "ola sou o Allan" I would like to keep this text divided by e.g., 2-on-2 chars. How can I do this?
-
0
votes1
answer1178
views -
0
votes1
answer1247
viewsQ: Solve duplicate items in Dict in Python 3
I’m having trouble with my dict. I need it not to delete duplicate key values. I have a style tuple lista_tupla = [(1, [1, 2, 3, 4]), (2, [5, 6, 7]), (3, [7, 8, 9]), (3, [10, 11, 12]), (4, [13, 14,…
-
0
votes1
answer105
viewsQ: Problem in Dict class and merging large amount of elements per Python Dict
Hi, I’m having trouble with dict. I have two lists: lista1 and lista2, both the same size. When I execute the command: dicionario = dict(zip(lista1, lista2)) produces a dictionary "smaller" than the…
-
0
votes1
answer102
viewsQ: Python 3 dicts and zip problem
I’m having trouble with my job dict(zip(x, y)) when I pass as parameter the two lists (x and y) the zip does not create the list of the original size, randomly creates the list in the original size,…
-
0
votes3
answers72
viewsA: Make copies of lists at certain positions with Python
I found a solution, but I don’t know if it’s right: l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] percent_l = 0.5 TAM = len(l) taxa_c = int(percent_l * TAM) print("taxa_c",taxa_c) new_list = [] for i in…
-
3
votes3
answers72
viewsQ: Make copies of lists at certain positions with Python
Hello, please, I would like to copy a certain list in python. The total list size is 150 and I wish to remove the last 50 elements from the list. Here I will represent a list 100 times smaller, ie…
-
1
votes2
answers74
viewsQ: Choosing an index from a list
I have a list: l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] I would like to choose a value between the indexes 6 and 14 of this list, but do this 5 times and store these values in another…
-
0
votes2
answers3050
viewsQ: Scroll through a Dict until it is empty in Python
How do I go through while a list of values and keys is non-zero, just add the values (values()) in a list? The code I have is this: hey = ['item1', 'item2', 'item3', 'item4'] print("hey", hey) lol =…
-
2
votes1
answer235
viewsQ: Distance count between one element and each other in a list (Python)
I have a list that symbolizes a timeline: linha_tempo = [1107, 1107, 0, 1104, 1104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1106, 1106, 0, 0, 0,…
-
3
votes1
answer881
viewsQ: Nested Functions in Python
How do I do nested functions in Python? Another question, because I always need to use the self parameter, and I’ve already put parameters in the function? For example, it is considered that the…
-
4
votes1
answer1956
viewsQ: While timer in Python
How to make a timer in while? I would like to run a while, and do something, e.g. a print "hello" run print "hello" for 1 hour for example.
-
3
votes2
answers1609
viewsQ: Random distribution in lists with python
I have a list: li = [0, 0, 2313, 1221, 0, 1333, 66, 0, 0, 0, 0] and another list of lists, where: The list of lists is called disciplines (below). The lists that are within disciplines, are also…
-
3
votes1
answer206
viewsQ: Check current index and next index equal to zero python
I need to scroll through a list in Python as for example: l = [2313, 1221, 1333, 66, 0, 0, 0, 0] I would like it if the current element and the next on the list are zero replaces the current and…