Python error: TypeError: 'str' object is not callable -


i new python , stackoverflow, apologies if don't know much. have picked python, , got started it. have been attempting make login admin thing, seem getting error. have tried using statement, seem error: typeerror: 'str' object not callable here's code...

username = input("please enter username: ") name in username (3):     if username == 'admin':         break     else:         print("you've given incorrect credentials thrice.")         import sys         sys.exit("exiting...") while true:     password = input("please enter password: ")     if password == 'khs9':         break  print("welcome admin!") 

any on this?

edit

apologies if not clearer, attempting try , make in need type in. loop used try , sentence "please enter username" repeat 3 times, show sentence "you've given incorrect credentials 3 times" if input not match have set (i set 'admin')

well, what's that?

for name in username (3): 

username string, not function.

if want 3 first letters, do

username = username[3]

and script:

username = input("please enter username: ")[5] if username == 'admin':     break else:     print("you've given incorrect credentials thrice.")     import sys     sys.exit("exiting...")  while true:     password = input("please enter password: ")     if password == 'khs9':         break  print("welcome admin!") 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -