Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Fixed // Help! Error when removing from list.
-
Works!
Very new to Python... However, I wrote this little list making script.
If I run this, and go to my def Edit(), the script errors out when its asked to remove the item from the list using the user input. If the item in the list is just a single character, it succeeds without error. Any ideas?<code>
import console
list = []def view():
print("Viewing Data")
sortlist = sorted(list)
print "\n".join(sortlist)
x = raw_input().title()
if x == "Q":
returndef add():
print("In Adding Mode")
sortlist = sorted(list)
print "\n" .join(sortlist)
x = raw_input().title()
if x == "Q":
return
else: list.append(x.title())
console.clear()
add()def edit():
print("Edit List, Remove?")
sortlist = sorted(list)
print "\n" .join(sortlist)
x = raw_input().title()
if x == "Q":
return
else: list.remove(x)
console.clear()
edit()while True:
console.clear()
choice = ["[A]dd to list" , "[V]iew List" , "[E]dit List"]
print("List App")
print('\n'.join(choice))
print("Use 'q' to Exit")
x = raw_input().title()
if x == "A":
console.clear()
add()
elif x == "V":
console.clear()
view()
elif x == "E":
console.clear()
edit()
</code> -
'THIS' not in ('This', 'Is', 'Text')
Add() calls x.title() but Edit() calls x.upper().
Change all calls to upper() into calls to title() and your script should work.
Also 'while True' is probably easier to understand (and type) than 'while 0 == 0'.
-
I appreciate the help! Thank you.