osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Flag control variable


On 02/11/2014 11:55 AM, luke.geelen at gmail.com wrote:
> hey, i got another problem now,
> if i use the imterpreter to do 3 * 4 it gives twelve
> the script gives 3333?
> any tips

 >>> 3*4
12

 >>> "3"*4
'3333'


Multiplying two integers produces the result you expect.

Multiplying a *string* by an integer is what you are doing. (And it just 
repeats the string a number of times -- not what you want.)

Your code used to have int(...) to convert the string supplied by 
sys.argv into integers.  What happened to them?

Gary Herron