printing to files in python

M

Matthew Wilson

Hi-

I want to print stuff like:

to a file, but when I do:

I get errors. What am I missing?
 
P

Peter Otten

Matthew said:
Hi-

I want to print stuff like:


to a file, but when I do:


I get errors. What am I missing?

Apart from using str as a variable name, which is bad style, there is
nothing wrong with the code you have posted.
It would help, if you would also post the values of d1 and prob and cut and
paste the actual traceback.
Using the insufficient information you provide, prob could be an
incompatible type, e. g. a string
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: float argument required

or you are ot allowed to write into the specified file:
Traceback (most recent call last):

Or something completely different...

Peter
 
T

Tom Hanks

Matthew Wilson said:
I get errors. What am I missing?

What are you missing? You are missing including your actual errors
in this question.

The only error I get when running your code (Python 2.3, Windows)
is "d1" and "prob" aren't defined. If I fix that then "out.txt" is
written as expected.

TTFN,
Tom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,342
Members
48,018
Latest member
DelilahDen

Latest Threads

Top