954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Python noob: adding to lists error

I don't know if I can't find my problem, or I'm just getting my keywords wrong when searching for a solution, but I can't solve it.

I'm getting problems with adding values to lists, here is my code:

x=[]
a=raw_input ("Hello, add your first database entery")
b=raw_input ("Hello, add your second database entery")
c=raw_input ("Hello, add your third database entery")
d=raw_input ("Hello, add your fourth database entery")
x.append(a)
x.append(b)
x.append(c)
x.append(d)
print (x)


Upon entering; 1,2,3,4 for the questions, I get this output:

[u'1', u'2', u'3', u'4']

What's with the u'x' I'm getting?

georgeoshardo
Newbie Poster
15 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

unicode string literals.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

Solution? :P

georgeoshardo
Newbie Poster
15 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

If you tell what is problem,I do not see any.

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

Sorry, I didn't phrase it correctly. I'd just like to stop showing the 'u' before each value in the list. Thanks :)

georgeoshardo
Newbie Poster
15 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

Why you do not print each value in list or join list values and print the string?

# back port input as raw_input if we run Python2
try:
    input = raw_input
except:
    pass

x = [input ("Hello, add your %s database entery: " % count) for count in ('first', 'second', 'third')]
print(', '.join(x))
pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: