Is ++ operator not available in Python?


It says invalid syntax for count++

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

def fizz_count(x):
    for i in x:
        if i=="fizz":
    return count
print fizz_count(drink)


Use += for addition, -= for subtraction.

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


Thank you...That works!


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


Yes, I found some explanations here.


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


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


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


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


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