Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8626805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:07:14+00:00 2026-06-12T08:07:14+00:00

im very new to python, Im trying to count how many x I have

  • 0

im very new to python, Im trying to count how many x I have in a 2D array, but list.count(x) gives me 0, but i know its not zero.

Im showing all my code. This code should do: read name and age from file, take maximum and minimum age and print in other file ALL with the same maximum and minimum age.

with open("duomenys.txt") as d: 
   sar = [line.split() for line in d]
max = 0
min = 200

for index, item in enumerate(sar):
    if int(sar[index][1]) > max:
        max = int(sar[index][1])
        pozmax = index

for index, item in enumerate(sar):
    if int(sar[index][1]) < min:
        min = int(sar[index][1])
        pozmin = index

with open('vyr_jaun.txt', 'w') as d: 
    d.write (sar[pozmin][0]+' '+sar[pozmin][1]+'\n')
with open('vyr_jaun.txt', 'a') as d: 
    d.write (sar[pozmax][0]+' '+sar[pozmax][1])

this writes only one name and age in file

my duomneys.txt file:

Justas 23
Mantas 18
Rokas 33
Anzelmute 69
Ruta 11
Vilius 2
Monika 6
Petras 17
Stasys 26
Zose 13
Jurgis 2
Borisas 69
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:07:15+00:00Added an answer on June 12, 2026 at 8:07 am

    (note that your ages in the array are strings. This is not a problem.)

    what = str(9) # whatever you are searching for
    count = 0
    for name,age in array:
        if age == what:
            count += 1
    
    print("there are",count,"people with the age",what)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to Python and I have been trying to detect missing
Hey I am very new to python but I am trying to make a
I am very new to python and have no idea what I'm doing but
I am very new to Python, and trying to figure out how to create
Very new to python and can't understand why this isn't working. I have a
I very new to Python, and fairly new to regex. (I have no Perl
I am very new to python programming and have yet to buy a textbook
I am very new to Python and I have a json news feed that
I'm very new to python. two days. trying to get a plot working with
I'm very new to Python and multithreaded programming in general. Basically, I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.