Count occurrences in a list in Python

 list1=['192.168.0.1',22,'root',22,'redhat',22]

y=0

for x in list1:

    if x == 22:

        y=y+1

print(y)

Share on Google Plus

About Md. Shahzad Alam

I am a passionate cloud and DevOps professional specializing in Linux and open-source solutions. Through this blog, I share my knowledge and experience with the community, offering tips and insights on cloud technologies and DevOps practices.
    Blogger Comment

0 comments:

Post a Comment