0

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

8th Oct 2021, 2:40 PM
NandhaKumar
NandhaKumar - avatar
3 Answers
+ 2
Then its better to warp your program into function if your condition will be fail in else part you can again call function
8th Oct 2021, 2:58 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
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
8th Oct 2021, 3:09 PM
Erlénio.RS
Erlénio.RS - avatar
+ 1
Hope it help :) name = input ("Enter the name here" :) if (name == "Nandhakumar"): print ("a") else: print("You entered wrong string..")
8th Oct 2021, 4:12 PM
Indira
Indira - avatar