List logic - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: List logic (/thread-2968.html) Pages:
1
2
|
RE: List logic - Low_Ki_ - Apr-23-2017 so here is another one... how do I get the \ in invalidChars list without it showing up as double \\ def getUserInfo(): while True: print('Enter a valid username: ') username = input() invalidChars = '!@#$%^&*()+=~`{}|[]:;"<,.>/ ?\\' invalidList = [] for l in invalidChars: invalidList.append(l) print(invalidList) break getUserInfo()
RE: List logic - wavic - Apr-23-2017 for chars in list(zip(*grid[::-1])): print(''.join(chars)) I was lazy and found how to rotate the matrix on SO. :-)
RE: List logic - Low_Ki_ - Apr-23-2017 (Apr-23-2017, 04:21 AM)wavic Wrote:for chars in list(zip(*grid[::-1])): print(''.join(chars))I was lazy and found how to rotate the matrix on SO. :-) NIIIIOCCCCEEEE dudeeee :D haha thanks :P I've played with this until my brain aches... i know im missing something simple... can someone please help. I'm just trying to compare the username to characters in the invalidList to make sure no illegal characters are allowed in a username: def getUserInfo(): while True: print('Enter a valid username: ') username = input().lower() invalidChars = '!@#$%^&*()+=~`{}|[]:;"<,.>/ ?\\' invalidList = [] for l in invalidChars: invalidList.append(l) for x in username.split(): for j in x: if j in invalidList: print('oops') else: break if any([x in invalidList for x in list(username)]): print('oops') else: breakAm i close? lol... Ahhh... There it is: for x in list(username): if x in invalidList: print('oops') |