def random(fileName)

    setup = open(fileName, "r" )
    z = setup.readline()
    waiting = stack()
    for line in setup:
        customerNum, arrivalTime, serviceTime = line.split()
        plane = Customer(customerNum, arrivalTime, serviceTime)
        push(waiting, plane)
    setup.close()
    print "The data file specifies a", z, "-server simulation."
    print "There are", len(waiting) , "arrival events in the data file."

This is the output, I tried a bunch of stuff but I get that line break after the variable z every time!
The data in the text file is ran through a clas I created but that has not effect with this print statement??

Please Enter a Filename. test.txt
The data file specifies a 5
-server simulation.
There are 1000 arrival events in the data file.
linux2[23]%

Recommended Answers

All 6 Replies

change z = setup.readline()
to z = setup.readline().strip('\n')

that worked thanks, how about removing the space that comes after z???
I want "-server simulation." after z or the "5" in this case, just without that space
output:

Please Enter a Filename. test.txt
The data file specifies a 5 -server simulation.
There are 1000 arrival events in the data file.
linux2[24]%

print "The data file specifies a "+ z+ "-server simulation."

I'm not sure if it'll work, I currently don't have an active python ide/compiler.

I feel dumb, it worked....I thought I would get that error message cannot concatenate blah blah blah you know the rest. Cheers

setup.readline().strip('\n')

returns a string, thus concatenating strings into the print expression.

You are very right, sometimes in other situations I get an error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.