Questions tagged as 'python-3.x'

2
answers

Create dictionary from a list

I have this list: laboratorio= [ [’pol’, (’hematies’, 4430000), (’basofils’, 0.5), (’calci’, 9)], [’josep’, (’hematies’, 5130000), (’hematocrit’, 40)], [’enrica’, (’hematies’, 4800000), (’calci’, 11.2), (’colesterol’, 2.3)], [’paco’, (’calci’,...
asked by 03.06.2018 / 23:51
2
answers

create a json file in Python 3.6.1

I want to create a json file and save it in a path x, below the code I'm occupying. import json import os ruta = {} ruta['nombre']= 'Jose' ruta['edad']='15' ruta['nacionalidad']='Mex' carpeta = 'C:%sPruebas' % os.sep os.chdir(carpeta) #esta es...
asked by 08.02.2018 / 01:01
1
answer

"List index of range" with list entered by keyboard

When I run my Python script, why do I get the error:    List index out of range although the index exists in the list? Here is my code: a=[input()] b=input() c=int(input()) d=[a[0], a[2]] print(d) When executing it, this is the erro...
asked by 14.02.2018 / 06:49
3
answers

Detect matches in multiple files with Python

Hi, I am new programming and I have been experimenting doing some scripts that have helped me a lot in my work, I would like in this case to be able to advance more with a script but I can not find a way to achieve what I want to do. My scrip...
asked by 29.12.2016 / 16:56
1
answer

How to make the python for the same function as in c ++

python code nx = 5 ny = 2 a=[[0]*nx]*ny for x in range(0, ny): for y in range(0, nx): a[x][y]=x * nx + y print(x * nx + y) print("===========") for x in range(0, ny): for y in range(0, nx): print(a[x][y]) c +...
asked by 20.03.2017 / 05:16
2
answers

'int' object is not subscriptable. Lists in Python

Good afternoon, I'm doing a simple didactic program that is responsible for reaching an X number with certain operations. My code is as follows: ##Los numeros de la persona numeroP1 = [0,0,0,0] numeroP2 = [0,0,0,0] ##Los numeros de la computad...
asked by 22.10.2016 / 20:26
2
answers

Convert date to string in date format

I'm trying to convert the date format    November 6, 2018 in    11/6/2018 as follows: datetime.datetime.strptime(fecha_inicio_,'%d-%B-%Y') and I get the following error, I was trying other convinations but I always get the sam...
asked by 01.11.2018 / 17:17
1
answer

how can I do for while to repeat the variable 'name' a certain number of times?

def fun (): re_ingresar = True num_nombres = int(input('cuantos nombres vas a escribir?')) while (re_ingresar): nombre = input('escribe un nombre:') #el output te repite 'escribe un nombre' infinidad de veces, #pero estoy trat...
asked by 05.11.2018 / 02:18
1
answer

Error in Python IndentationError: unindent does not match any outer indentation level

I have this code in Python version 3.6 #! /usr/bin/python #-*- coding: utf-8 -*- import pxssh usuario = open("usuario.txt", "r") for usuario in usuario.read().split("\n"): password = open("password.txt", "r") for password in passwor...
asked by 17.10.2018 / 03:31
1
answer

Pass different values to a string without repeating the same

I need to pass different values to the url, as you can see in the example, first I pass the values contained in dt_3, the problem is that I need to pass the rest of the values to all the url, that is, dt_7 and dt_31. How can I simplify the pr...
asked by 17.10.2018 / 15:43