0

Consider the following code; I want to print the array Ptimes 3 spaces from the beginning of console screen. I have tried

print "   %s" %(Ptimes) 

when I use this form nothing printed it says that there is error "all arguements covered due too string formatting.

the original worked code is:

PN = input("   Enter each process time following by its arrival time separated by comma: ")

Ptimes = PN[::2]  
Atimes = PN[1::2]
print    Ptimes
print    Atimes 

1 Answer 1

1

Ptimes is a tuple, and Python wants to find placeholders for each *element in Ptimes. Wrap it in a tuple (add a comma) instead:

print "   %s" % (Ptimes,)

Demo:

>>> Ptimes = ('foo', 'bar')
>>> print "   %s" % (Ptimes)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: not all arguments converted during string formatting
>>> print "   %s" % (Ptimes,)
   ('foo', 'bar')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.