This is a Doctor,Doctor it hurts when I do this question...but does anyone know why I get a "None" output when running from a module, and I don't get a "None" when I call a function from the Python Shell?
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
#As an exercise, write a function that takes a string as an
#argument and outputs the letters backward, one per line.
return " "
#I do get my backwards spelling, but at the end of that I get a "None". If I
#comment out the print statement "None" does not print. What is going on
#here? My if/else word[loopCount] apparently does nothing.
#this too gives me a "None" at the end.
All functions return 'None' unless you use the keyword 'return to return something else. The shell suppresses the 'None' return. If you did some_var = spellFrontwards(word) and then print some_var it would show you the 'None'
Instead of using print at the end you could just type spellFrontwards("frontwards") ad your function already does the printing or you could make the function build up a variable with what you want to print and return it, then your last print would work as expected.