Search Result

Collapse
4 results in 0.0013 seconds.
Keywords
Members
Tags
tuple
  •  

  • (python) for some reason file.readline() is only reading every second line

    why is this skipping readlines in what it returns? i went through debugger and found it thinks the second line of the txt file is the first and continues to skip every second line.
    Code:
    def get_distances(filename):
        opener = open(filename)
        d = {}
        while file.readline(opener) != '':
            '''converts a file with cities and distances into a dictionary with values
            of distances from one city to
    ...
    See more | Go to post

  • Anne Finch
    started a topic Creating a menu based program based on a list

    Creating a menu based program based on a list

    I am having issues creating a menu-driven program that should accept integers and calculate the mean and median values and display them. I'm not having trouble calculating the Mean or Median, but I am having trouble with configuring the list into the program.

    Code:
    #Main
    def main():
        array = [] #this would be the list, but what do i do with it?
        choice = displayMenu()
        while choice != '4':
    ...
    See more | Go to post

  • jeff4567
    started a topic Convert Tuple to String

    Convert Tuple to String

    I've got an issue where i'm trying to change names of a bunch of files in python. I've scoured the necessary directory and added the files to a list, and now im trying to remove the last 9 charecters from the filename and replace them with something new. When I try to take the letters off using fname =fname[-:9] its throwing me an error.

    here's what i've got so far. Thanks for the help.

    Code:
    import os, sys, string
    ...
    See more | Go to post
    Last edited by bvdet; Mar 24 '10, 06:33 PM. Reason: Add code tags

  • thesinik
    started a topic Search function not working.

    Search function not working.

    Code:
    import random
    import math
    
    t = tuple()
    
    def linsearch(key, l):
        count = 0
        index = 0
        t = tuple()
        for i in l:
            count += 1
            if key == i:
                t = (index, count)
                return t
            index += 1
        
    
    def binsearch(key, l):
        count = 0
        low = 0
        t = tuple()
        high = len(l) -
    ...
    See more | Go to post
    Last edited by thesinik; Nov 13 '09, 06:04 PM. Reason: fixed indents
Working...