def my_function(country = "Norway"):
print("I am from " + country)
my_function("Sweden")
my_function("India")
my_function()
my_function("Brazil")
语法错误:语法无效
答案 0 :(得分:0)
您的代码应该可以正常工作。
我在下面的PyCharm IDE中尝试过,它为我工作。
def my_function(country = "Norway"):
print("I am from " + country)
my_function("Sweden")
# Output = I am from Sweden
在命令行中尝试以下代码:
C:\Users\OmkarJ>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> def my_function(country = "Norway"):
... print("I am from " + country)
...
>>> my_function("Sweden")
I am from Sweden
>>> my_function("India")
I am from India
>>>