Is ++ operator not available in Python?


#1



https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/0/4?curriculum_id=4f89dab3d788890003000096

It says invalid syntax for count++

Aren't pre and post increment operators available in Python?


def fizz_count(x):
    count=0
    for i in x:
        if i=="fizz":
            count++
    return count
drink=["fizz","cat","fizz"]    
print fizz_count(drink)


#2

Use += for addition, -= for subtraction.

def fizz_count(x):
    count = 0
    for n in x:
        if n == "fizz":
            count += 1
    return count

#3

Thank you...That works!


#4

many programming language have a ++ or a --, python doesn't have this, i am sure if you really want to know, you might be able to find online why python doesn't have these


#5

Yes, I found some explanations here.


#6

what other types of programming languages have the ++ and -- ?


#7

In my knowledge, C, C++, Java have ++ and -- operators.


#8

Ok, thanks, I was wondering because my goal is to learn Python, Java, and Java Script


#9

javascript also has, and i believe ruby has as well. And i am sure there are manz more languages which have this (golang, scala maybe)

in fact, not having this operator is rare. Python is one of the few languages which doesn't have this


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.