Blaiiz wrote:Hey guys, I have an assignment to complete for my CSC course except I have no idea how to do this part of the assignment.
We're supposed to create a code to get the first of word of a desired line that the user inputs. We can't use "\n" in any way to count the lines (or make a code that outputs the desired line). The function has two parameters - (url, line_number). And we have to specifically use the "readline()" function instead of "readlines()" or any other form... the following code must be used:
"stream = urlopen(url)
line = stream.readline().decode()"
The only hint we were given was that we'd need more than one loop to execute the function. I'm not too sure if we can create multiple functions to help with the problem, but if not, how would you do it with just one defined function? Thanks in advance for the help!
In the future, use code tags rather than quotes (it's especially important for code with indentation, but I find it more aesthetically pleasing in posts in general).
We are happy to help with your homework, but we need to see some effort. You're told that you need multiple loops. What have you tried? Why did you try it, and why do you think it doesn't work? If you can't solve the problem, you should still write as much code toward solving the problem as possible. Are you able to iterate through all the available lines, at the very least?
Join the #python-forum IRC channel on irc.freenode.net for off-topic chat!
Please prefer not to PM members. The point of the forum is so that anyone can benefit. We don't want to help you over PMs/emails/Skype chats that others can't benefit from