469,286 Members | 2,547 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

user input and lists

23
Hi, Python is the first language for me to get into. I'm still really new and have a lot to learn, though...

Does anyone know how to allow users to append lists?

I tried

user.append = raw_input("Type in desired username ")

But apparently .append is read only. D:
Sep 21 '06 #1
4 5652
ghostdog74
511 Expert 256MB
you can't do that.

users = []
user = raw_input( "Enter user:")
users.append(user)
Sep 22 '06 #2
Bellum
23
Oh....Duh, nvm.

I've run into another problem, but from what I've seen, the proper sintax is

user.append(raw_input("Type in desired username "))

right?

I can't properly test it, because (after changing user to a list) my original code directly afterward doesn't work.

if len(user) > 4:

Doesn't work because it's asking how many objects are in the list. D:

I tried

if len(user[0]), too, but to no avail. I think I've discovered a better way to do what I want, so I'm going to revert to user being a simple string, but I'd still like to know.


EDIT: Oh, ok.
Sep 22 '06 #3
ghostdog74
511 Expert 256MB
it should be users.append(raw_input("Type in desired username "))
if you declared "users" as a list

len(users) will show how many items are inside the list
Sep 22 '06 #4
Bellum
23
I know, but the intention was to find the number of characters in a particular object in the list. A 'no less than five characters' thing.

I don't really need it anymore because I'm changing the way I'm going about this particular problem, but is it possible to do that using the len function on lists?




Thanks for the help, mate.
Sep 22 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

15 posts views Thread by Joshua Beall | last post: by
5 posts views Thread by Raffi | last post: by
3 posts views Thread by zlst | last post: by
reply views Thread by JDC | last post: by
8 posts views Thread by Olivier | last post: by
18 posts views Thread by sebastian | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.