cant use def command
python at mrabarnett.plus.com
Sat Feb 2 16:35:45 EST 2019
On 2019-02-01 15:49, mb1541def 0 wrote:
> I need help on the def command.
> My script:
> Import os
> def Test():
> someone please help,it gives me an error in python 3.
> I did everything right.
You didn't say what the error was, so I'll just comment on what I can
see. Some of what I'm seeing might be due to whatever software or forum
you're using to post the message, messing it up.
1. Capitalization: it should be 'import', not 'Import'.
2. Indentation: the body of the function 'Test' should be indented more
than its 'def' line.
3. You're referring to 'Test' before it's defined.
4. You're not calling 'Test', but merely referring to it by name. To
call a function, you need to add parentheses, even if they are empty.
5. Quotes: only plain quotation marks should be used; I'm seeing 'smart'
This should work:
More information about the Python-list