File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ # We can found it at the source code
2+
3+ import requests
4+
5+ # Get the Source Code
6+ http = requests .get ("http://www.pythonchallenge.com/pc/def/equality.html" )
7+
8+ # Remove the line breaks of the text in the source code
9+ source_code = http .text .replace ("\n " ,"" )
10+
11+ # Separete the text by the comment mark
12+ textos = source_code .split ("<!--" )
13+
14+ #Create a list that I will use to storage the letters
15+ letters = []
16+
17+ # "posição" will be used to track the letter index
18+ posição = 0
19+ for letter in textos [1 ]:
20+ if letter .islower ():
21+ # Get the four letter before and after
22+ seleção = textos [1 ][max (posição - 4 ,0 ): posição + 5 ]
23+ primeira = seleção [0 ]
24+ ultima = seleção [- 1 ]
25+ # Check if the first and the last one letter in the selection is lowercase
26+ if primeira .islower () and ultima .islower ():
27+ tres_primeiras = seleção [1 :4 ]
28+ tres_ultimas = seleção [5 :- 1 ]
29+ #Check if the three letters before and after are uppercase
30+ if tres_primeiras .isupper () and tres_ultimas .isupper ():
31+ letters .append (letter )
32+
33+ posição += 1
34+
35+ # Join the letters of the list
36+ print ("" .join (letters ))
37+
38+ # http://www.pythonchallenge.com/pc/def/linkedlist.php is the answer
You can’t perform that action at this time.
0 commit comments