[Tutor] Problem with little program

Alan Gauld alan.gauld at btinternet.com
Sun Mar 14 02:30:51 CET 2010


"C M Caine" <cmcaine at googlemail.com> wrote

> That's an easy mistake to make. Simply use raw_input instead of input.
> The former will always return a string, the latter treats whatever you
> enter as executable python code.

Whilst I agree with the general principle to use raw_input, I don't
see how we can say that it is the problem here. Indeed so far as
I can tell we don't even know what the problem here is other than
that the OP is trying to call the function he has defined in
another file.


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


On 13 March 2010 18:56, Marco Rompré <marcodrompre at gmail.com> wrote:
>
> Hello I have a little problem, I am trying to define a function 
> ligneCar(n, ca) that would print n times the caracters ca.
> For now I have the user entering a short sentence corresponding to ca.
> Here is my code:
> def ligneCar(n,ca):
> c=0
> while c<n:
> print ca
> c+=1
> ca = input ('Enter a short phrase : ')
> n = input ('Enter how many times you want : ')
> Thats the definition of my function ligne_Car
> then in another python file
> I want to recall my function ligne_Car but it is not working.
> Please help me




More information about the Tutor mailing list