Urgent help | Sololearn: Learn to code for FREE!


Urgent help

name = input ("Enter the name here" :) if name == "Nandhakumar" Print ("a") else: while name: If I entered wrong string it will go to else block. I Don't know how to write else block statement if I entered wrong string

10/8/2021 2:40:49 PM


3 Answers

New Answer


Then its better to warp your program into function if your condition will be fail in else part you can again call function


def getName(n): if n != "Nandhakumar": getName(input()) else: print("correct name") getName(input()) this code will give an error if you input the wrong name here on the ground, Because sololearn reads only in the startup


Hope it help :) name = input ("Enter the name here" :) if (name == "Nandhakumar"): print ("a") else: print("You entered wrong string..")