Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help pls!
#1
uncomfirmedusers = ['bob','joe','mikey']
comfirmedusers = []

while uncomfirmedusers:
currentuser = uncomfirmedusers.pop()


print("veryfing user: " = currentuser())
comfirmedusers.append(currentuser)

print("\nThe following users have been confirmed:")
for comfirmedusers in comfirmedusers:
print(comfirmedusers.title())

everytime i compile this,this line
print("veryfing user: " = currentuser())

it says you cant use a keyword for an expression
im confussed,please help
Reply
#2
Going forward: Make your subject line descriptive. Use code tags. Post the full traceback, not just one line from it.

As for your question, I didn't try running the code, but anything like
"string" = function_call()
isn't gonna work. What do you intend for such lines to do? I see two of them.
Reply
#3
print is a function. When you call a function the arguments are separated by commas, not '='.

currentuser is not defined as a function anywhere. Since it is not a function you cannot call it using currentuser().
print("veryfing user: " = currentuser())
# should be
print("veryfing user:", currentuser)
Though this does not cause a crash it is still a really bad idea:
for comfirmedusers in comfirmedusers:
    print(comfirmedusers)
Do not use the same name to refer both a list and an item in the list. When the above code completes the original list is gone. Instead do this:
for user in comfirmedusers:
    print(user)
confirmedusers is a list of strings. Well it would be if there weren't so many other errors. A list does not understand .title and doesn't know how to do .title().

You have one thing right. You are really confused. I think you need to start out with some simpler examples, or a few guided tutorials. You should also do some reading to understand the basics of the language. Not fun I know, but a lot better than the heaps of frustration heading your way otherwise.

Good Luck.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020