Hi! I am new to Python. How to print number+string+array?

Off course python doc has info about this.
This is very basic off any language.

You can look at this.

i = 55
print i

s = 'hello'
print s

l = [1, 2, 3]
print l

print('string say %s i am an integer %d this is a list %s' % (s, i, l))

<type 'int'>
<type 'str'>
[1, 2, 3]
<type 'list'>
string say hello i am an integer 55 this is a list [1, 2, 3]

I know about types and stuff, I can do Actionscript 2, JavaScript and php. But I did not know about the %l, only about %d and %f.
But this does not work:

print 'hey%l'%abc

I don't know why, because I can't see the error because when it happens, the window automatcally closes.

EDIT: Not with %s either.

Edited 6 Years Ago by ErlendHL: %s

IDLE 2.6.5      
>>> abc = [1,2,6,2,4,2,4,6,3,43,6]
>>> print 'hey%l'%abc

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    print 'hey%l'%abc
ValueError: incomplete format
>>> print 'hey %s' % abc
hey [1, 2, 6, 2, 4, 2, 4, 6, 3, 43, 6]

It works in Python Shell, but when I try to make a .py file, it just don't work

Here are all my code:

import time
abc = [1,2,6,2,4,2,4,6,3,43,6]
print 'hey%s' % abc

time.sleep(10000000)is a vey long time and will give an error message.
OverflowError: sleep length is too large

time.sleep(5) #wait for 5sec
You can try this

import time
abc = [1,2,6,2,4,2,4,6,3,43,6]
print 'hey%s' % abc
print 'What not again %s' % abc

Edited 6 Years Ago by snippsat: n/a

The thing is that as soon as the code stops, the window is crossed out.
So I need to write at the end:

while True: pass



But yeah it works when I say time.sleep(100) instead

This question has already been answered. Start a new discussion instead.