Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f2b35ca

Browse files
Challenge 3 Solved
1 parent 8a1bf4d commit f2b35ca

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

‎Challenges/Challenge_3.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /