CodeCademy-Python Learning:Practice Makes Perfect学习笔记-“Something went wrong :(”报错

Practice Makes Perfect

Let's create a few more functions just for good measure.

def shout(phrase):
    if phrase == phrase.upper():
        return "YOU'RE SHOUTING!"
    else:
        return "Can you speak up?"

shout("I'M INTERESTED IN SHOUTING")

 
  

The example above is just there to help you remember how functions are structured.

Don't forget the colon at the end of your function definition!

Instructions
  1. First, def a function called cubethat takes an argument called number. Don't forget the parentheses and the colon!
  2. Make that function return the cube of that number (i.e. that number multiplied by itself and multiplied by itself once again).
  3. Define a second function calledby_three that takes an argument callednumber.
  4. if that number is divisible by 3,by_three should call cube(number) and return its result. Otherwise, by_threeshould return False.

Don't forget that if and elsestatements need a : at the end of that line!

def cube(number):
    number = number ** 3
    print number
    return number
    
def by_three(number):
    if number % 3 == 0:
        return cube(number)
    else:
        print "2222"
        return False
        
number = input("number: ")

程序一直报错,且有错误弹窗,提示“something went wrong :( Click Close to try again or refresh the page”
如图:

试过不同的浏览器,均出现此错误,且console窗同时报红字错误:

对比此题其他人通过的代码,发现并没有错误,仔细检查之下,竟发现是有一个‘:’用的是中文状态下的符号,新手果然是比较没经验,不过错误是自己检查出来了,下次同类问题还是涨了一点点经验了。

你可能感兴趣的:(Python)