Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+4 votes

When I run the code on thonny with def main(): and printPowersofN(4,3), it runs perfectly, printing 1 4 16 64, but when I place the function in moodle it only prints out 1 4. Giving an error message of NameError: name 'printPowersOfN' is not defined. Why is it that the code only works in thonny, but not in moodle?

asked in old_CSC201 by (1 point)

1 Answer

0 votes

My test code in Moodle is looking for a particular function name. In Thonny as long as the function call and funciton definition use the same name, you could name the function anything.

My test code has the function call, at it is looking for printPowersOfN (notice the capital F in oF). If you change the name of the function in your function definition to have a capital F, you should be good to go.

Thanks for asking in the Q&A!

answered by (1 point)
...