'I want modify this code as when a user gives right name but wrong password code must run from enter password not from enter username again
while True:
    print("who is this?")
    name=input()
    if name!='shubh':
        continue
    print("hi its you shubh. type your password")  
    password=input()
    if password!="shubh": 
        print("try again. wrong password")
    elif password=="shubh":
        break
print("access granted")
when the user gives correct id but wrong password code must run from password input and not from start
Solution 1:[1]
You could try as @ewong suggested
while True:
    print("who is this?")
    name=input()
    if name=='shubh':
        break
    print("Please try again")
while True:
    print("hi its you shubh. type your password")
    password=input()
    if password!="shubh":
        print("try again. wrong password")
    elif password=="shubh":
        break
print("access granted")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | Sanjay SS | 
