why do i get this error File main py line 18 message connectionSocket recv 1024 IndentationError expected an indented block and how to make it write

0 votes

print ("Ready to serve...")

connectionSocket, addr = serverSocket.accept()

try:

message = connectionSocket.recv(1024)

print message,'::',message.split()[0],':',message.split()[1]

filename = message.split()[1]

print filename,'||',filename[1:]

f = open(filename[1:])

Sep 8, 2020 in Python by anonymous
• 120 points
1,365 views

1 answer to this question.

0 votes

Hello,

The error itself explain what's the problem.In Python, all the code that you type is arranged via correct whitespaces and therefore if at any instance you have a bad indentation, the overall code will not run and the interpreter will simply return an error function.

Make those changes and your code will work fine.

To know more what is indentation error you can refer this:https://www.edureka.co/blog/indentation-error-in-python/

Hope this helps!!

Thank you!!

answered Sep 8, 2020 by Niroj
• 82,740 points

Related Questions In Python

0 votes
1 answer

I was written the python program, am getting error message "IndentationError: expected an indented block"

Hi@Thiyagarajan, You have one else block in your ...READ MORE

answered May 27, 2020 in Python by MD
• 95,360 points
2,675 views
0 votes
1 answer

I've been trying to run this code, but the error says "Expected an indented block" for the line, " word_as_list[index] = guess."

Hi, @Paradox, The error message IndentationError: expected an indented ...READ MORE

answered Nov 21, 2020 in Python by anonymous
• 65,870 points
386 views
–1 vote
2 answers
0 votes
1 answer

I want to download a file from the website by web scraping. Can anyone explain how to do this in jupyter lab (python) with an example?

Hey, Web scraping is a technique to automatically ...READ MORE

answered Apr 7, 2020 in Python by Gitika
• 65,870 points
1,160 views
0 votes
1 answer

what does this line fout.write("</{}>\n".format(opentags.pop())) do?

It closes one tag actually, opentags is ...READ MORE

answered Nov 10, 2020 in Python by Gitika
• 65,870 points
114 views
0 votes
1 answer

what do you mean by static block in java?

Static block is used for initializing the ...READ MORE

answered Jun 18, 2018 in Java by scarlett
• 1,290 points
414 views
0 votes
1 answer

cant get around error ''expected an indented block'' in python(jupyter lab)

Hi@David, First thing, don't share your credentials with ...READ MORE

answered Nov 19, 2020 in Data Analytics by MD
• 95,360 points
246 views
0 votes
1 answer

How do I get the path and name of the file that is currently executing?

Hello @kartik, Since Python 3 is fairly mainstream, ...READ MORE

answered May 11, 2020 in Python by Niroj
• 82,740 points
1,068 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP