This forum is now read-only. Please use our new forums at discuss.codecademy.com.

How to use APIs with Python Forum

View Course » View Exercise

283 points
41aeba018fb10cc4d4af5e80c0401b58?s=140&d=retro
Submitted by
Tony paul
about 4 years ago

Why do we need [559:1000]?

print kittens.text[559:1000] 

What is the relevance of [559:1000] here?


7 votes

permalink

Check placekittens.com website source :) Kitten in asci art is on 559. - 1000. character in html source :)

1306 points
5193286c843e13f0b8001b49_776056603
Submitted by
Tomáš Hartmann
almost 4 years ago


5 votes

permalink

Go to http://placekitten.com and press f12 (maybe in some browsers another key but in Chrome it is f12) to see the code of the page — there is an html comment in the head:

<!--

    BREAKING NEWS: KITTENS FKN LOVE YARN

                      __     __,
                      \,`~"~` /
      .-=-.           /    . .\
     / .-. \          {  =    Y}=
    (_/   \ \          \      / 
           \ \        _/`'`'`b
            \ `.__.-'`        \-._
             |            '.__ `'-;_
             |            _.' `'-.__)
              \    ;_..-`'/     //  \
              |   /  /   |     //    |
              \  \ \__)   \   //    /
               \__)        './/   .'
                             `'-'`

    -->

And the number of the first character of this "picture" — 600, but don't remember, that in Python we start counting from zero, so in Python it looks like 559. It isn't hard to guess that 1000 — number of the last character of this picture.

P. S.: Sorry, if my English isn't very good — I'm from Russia :)

251 points
53061d07282ae39afd001ba4_84594746?awsaccesskeyid=akiajkz7qvqfd72xnj3q&expires=1511465393&signature=jtj6f1l3h6%2bodnqactv9wcvz4we%3d
Submitted by
Daniel Kolesnichenko
over 3 years ago


1 vote

permalink

I'm sorry i still don't get it. I understand that u've got to go and check the code on the site by pressing f12. But still how did you find out that the code for the kitten started on 559 and ended on 1000. I mean is there any means by which you can find that?
Any help will be appreciated.

570 points
53a40260548c35870700254e_544981916
Submitted by
mrsanghvi
over 3 years ago

2 Comments

5193286c843e13f0b8001b49_776056603 Tomáš Hartmann over 3 years ago

You could copy - paste the source code from placekitten.com into for example MS Word - and check on which character it starts.

Or you just could keep trying different text slice in python, until you receive the kitten. If this is what you asked.

53a40260548c35870700254e_544981916 mrsanghvi over 3 years ago

Thank you-that was what i was looking for.


0 votes

permalink

import requests

kittens = requests.get('http://placekitten.com/')
text = kittens


print kittens.text[559:1000]

212 points
E496244cf0eb7b6bd9d19e9f52615959?s=140&d=retro
Submitted by
bhartirawatbr
about 2 years ago