Questions tagged as 'python'

3
answers

syntax error in python 3?

Why does syntax error appear when executing this block? I can not find the reason: for Empleados in cursor: emplead = '\t'+ str(Empleados[0]) + '\t'+ str(Empleados[1]) + '\t' + str(Empleados[2]+ \ '\t' + str(Empleados[3] +'\t'...
asked by 13.07.2017 / 23:46
3
answers

Evaluate if a list of integers is triangular in python

By means of a python script I want to evaluate if a list is triangular, that is to say if it is increasing up to a certain element, and from that element it is decreasing. For example, the list [2, 4, 5, 7, 4, 3] is triangular, while the list [2...
asked by 26.09.2018 / 00:39
0
answers

Customize "prepopulation" in Django admin [closed]

I currently have a field that is automatically filled in by taking the value of two additional fields in order: team 1 and team two. I get the following result with this code within the Administrator class corresponding to the Match model:...
asked by 16.05.2016 / 17:34
3
answers

How do you compare 2 dictionaries to know if they have the same item or key?

I need to compare 2 dictionaries and return a dictionary with all the elment of both. Example: dic1 = {'a': 2, 'e': 5, 'u': 1} dic2 = {'a': 3, 'e': 2, 'i': 2} then return one of the two complete with all the elements: dic1 = {'a': 5, 'e':...
asked by 05.10.2018 / 22:57
2
answers

Repeat a print certain times in a while

numero1 = 1 print("Desde el") while True: print("Número {}".format( numero1 )) numero1 = numero1 + 1 print("hasta el") if numero1 == 11: break the result is: Desde el Número 1 hasta el Número 2 hasta el Número 3...
asked by 24.02.2018 / 21:22
2
answers

Group and add equal values from a python list

I have these 2 lists: list_ip = ["192.168.2.9", "192.168.2.8", "192.168.2.7", "192.168.2.6"] list_traffic = [ [u'192.168.2.9', u'23.67.224.83', u'10', u'2', u'*', u'*'], [u'23.67.208.186', u'192.168.2.9', u'10', u'1', u'*', u'*'],...
asked by 16.05.2017 / 15:52
1
answer

How to use the same virtualenv (python) in Windows and Linux?

I started using Windows and Linux recently in the same PC (installed in different partitions respectively and a third one for common files) but it turns out that the environments created in Windows are generated with the "Scripts" folder, and in...
asked by 05.03.2017 / 21:11
1
answer

Second forloop.counter does not print anything on screen

I am building a carousel of images using Foundation Orbit, for the part of the bullets I have an error when using two forloop.counter tags, I need them to print the carousel element number on the screen, one in "Humanized" form and the...
asked by 11.02.2016 / 20:47
1
answer

Concatenate two dictionaries without repeating field

I have two dictionaries with the same keys, one key value in common and the other different values, as follows: Colombia = {'stats': [{'value': [{'wins': 3}, {'ties': 1}, {'defeats': 2}], 'team': 'Colombia'}], 'cup': 41} Brasil =...
asked by 17.05.2016 / 00:46
1
answer

How the function emit () works in python

I'm starting in python, today the teacher explained us about the function emit and I use the following example: from PyQt5.QtWidgets import QMainWindow,QApplication from PyQt5 import uic from PyQt5 import QtCore import threading class Princip...
asked by 11.12.2018 / 00:30