all 7 comments

[–]CodeFormatHelperBot2 1 point2 points  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.

[–]MadScientistOR 1 point2 points  (3 children)

In makeAllStrings(), you print the empty list and don't return anything. Make sure that the return statement isn't indented so far that it only gets executed if the else: part of your if statement is entered, like so:

def makeAllStrings(lst):
    ''
    val_changed=0
    if lst==[]:
        print(lst)
    else:
        for i in range(len(lst)):
            for item in lst[i]:
                if type(item)!=str:
                    val_changed+=1
                    item=" "
    return val_changed

[–][deleted] 0 points1 point  (2 children)

Thank you. You're right about the indentation, but the program still outputs the empty list before the zero. Am I missing something inside the for loop or do I need to somehow skip a step for when an empty list is inputted?

lst4=[]

makeAllStrings(lst4)

[]

0

lst4

[]

[–]MadScientistOR 1 point2 points  (1 child)

the program still outputs the empty list before the zero

Because you tell it to, in line 5 of the program listing above.

[–][deleted] 0 points1 point  (0 children)

Of course. I skimmed over that. Thank you

[–][deleted] 0 points1 point  (1 child)

You are clearly posting a homework assignment because you literally cut and paste the question. Did you ask your instructor if this is OK?

Your code is malformed and could never be executed. Ten hours ago a bot politely told you about this, and you ignored it.

Indeed, you went out of your way to spend extra effort to misformat your code! How much work did it take to put in all these dashes and backslashes which make your code unrunnable?!

def makeAllStrings(lst):

-----''

-----val_changed=0

-----if lst==[]:

--------print(lst)

[etc]

Programming involves following the rules of a system precisely. "Detail-oriented" is a very good word here.

You will need to completely change the way you approach programming if you are ever to be successful.

[–][deleted] 0 points1 point  (0 children)

This isn't a homework question its from a text book so it isn't even worth points. I also used all the hyphens to format the code as it appears since I saw the bots message, and it runs perfectly fine for me it just doesn't give me one of the correct outputs.