您的程序运行良好。您只是没有通过prompt string,它会在终端上提示询问用户的输入:
a=[]
b=[]
for i in range(0,4):
m=int(raw_input(" Enter value for a list :"))
a.append(m)
for i in range(0,4):
n=int(raw_input(" Enter value for b list :"))
b.append(n)
print "list a looks like :-", a
print "list b looks like :-", b
结果如下:
Enter value for a list :1
Enter value for a list :2
Enter value for a list :3
Enter value for a list :4
Enter value for b list :5
Enter value for b list :6
Enter value for b list :7
Enter value for b list :8
list a looks like :- [1, 2, 3, 4]
list b looks like :- [5, 6, 7, 8]
raw_input(...)
raw_input([prompt]) -> string
Read a string from standard input. The trailing newline is stripped.
If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.
On Unix, GNU readline is used if enabled. The prompt string, if given,
is printed without a trailing newline before reading.
如果您只希望 integers 作为输入,您可以使用 input 内置函数,无需再次将其类型转换为整数。
a=[]
b=[]
for i in range(0,4):
m = input(" Enter value for a list :")
a.append(m)
for i in range(0,4):
n = input(" Enter value for b list :")
b.append(n)
input(...)
input([prompt]) -> value
Equivalent to eval(raw_input(prompt)).