dos puntos
Publicado por Eduardo (25 intervenciones) el 19/11/2016 19:47:26
Hola a todos un saludo, antes de nada perdonad si este no es el sitio adecuado para un tema tan básico, me gustaría saber qué significan los dos puntos entre i e i encerrados en un corchete bajo el bucle for
Les dejo el programa por si alguien puede por favor ayudarme con esto, he estado buscando pero no le tengo aún claro, gracias de antemano y un saludo.
1
kmer = genome[i:i+k]
Les dejo el programa por si alguien puede por favor ayudarme con esto, he estado buscando pero no le tengo aún claro, gracias de antemano y un saludo.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Open the input text file.
f = open('problem001.txt', 'r')
myDictionary = {}
# First line contains the string Text
genome = f.readline().rstrip('\n')
# Second line contains k
k = int(f.readline().rstrip('\n'))
f.close()
# Number of characters in the string
numChars = len(genome)
# Step through the string 1 char at a time and substring out each k characters
for i in range (0, numChars - k + 1):
kmer = genome[i:i+k]
if kmer in myDictionary:
myDictionary[kmer] += 1
else:
myDictionary[kmer] = 1
maxValue = 0
answer = ''
# Sort the keys in the dictionary
for w in sorted(myDictionary, key=myDictionary.get, reverse=True):
if myDictionary[w] >= maxValue:
maxValue = myDictionary[w]
answer += w + ' '
print w, myDictionary[w]
print 'answer'
print answer
Valora esta pregunta


0