Python in Pycharm


#1



Hi,
this may be a little off but may i know why does my code work on codecademy but not in pycharm? it shows syntax error when calling a function


#2

@tsukihikari,
Could you provide the code you are using....


#3
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def grades_sum(scores):
    total = 0
    for i in scores:
        total += i
    return total
    
print grades_sum(grades)

def grades_average(grades):
    ave = grade_sum(grades) / float(len(grades))
    return ave
    
print grades_average(grades)

sorry i forgot about that @leonhard.wettengmx.n


#4

@tsukihikari,
Have a try with

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def grades_sum(scores):
    total = 0
    for i in scores:
        total += i
    return total
    
print grades_sum(grades)

def grades_average(grades):
    ave = grades_sum(grades) / float(len(grades))
    return ave
    
print grades_average(grades)

#5

It does not seem to work in Pycharm...
the error given:

File "D:/Python/Random/fun.py", line 9
print grades_sum(grades)
^
SyntaxError: invalid syntax


#6

@tsukihikari,
try it with

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def grades_sum(scores):
    total = 0
    for i in scores:
        total += i
    return total
    
print(grades_sum(grades))

def grades_average(grades):
    ave = grades_sum(grades) / float(len(grades))
    return ave
    
print(grades_average(grades))

#7

It worked! Thank You! i was figuring if there was sum error in the coding(logic).


#8

@tsukihikari,
With google search
== discussions / opinions ==
pycharm print SyntaxError: invalid syntax site:stackoverflow.com
http://stackoverflow.com/questions/27029018/getting-errors-from-system-console-while-pycharm-console-executes-code-correctly