+ 1

Again I am stuck on indentation. Somebody please help me this

pin = input() try: int(pin) print("PIN code is created") except ValueError: print("Please enter a number")

26th Oct 2022, 7:14 AM
Kashish Khan
6 odpowiedzi
+ 2
pin = input() try: int(pin) print("PIN code is created") except ValueError: print("Please enter a number") # You need to give 4 spaces to each line inside the block
26th Oct 2022, 7:18 AM
Ratnapal Shende
Ratnapal Shende - avatar
+ 3
Riya you can use as much spaces you want but it must be consistent. but according to python convention we must use 4 spaces !
26th Oct 2022, 7:55 AM
Ratnapal Shende
Ratnapal Shende - avatar
+ 3
Oh, I usually use 2 spaces. it works ...Ratnapal Shende thank you
26th Oct 2022, 8:08 AM
Riya
Riya - avatar
+ 2
while True: pin = input("Enter a number : ") if pin.isdigit(): print("Pin is generated !") break else: print("Please Enter a number !") # just for fun :)
26th Oct 2022, 7:20 AM
Ratnapal Shende
Ratnapal Shende - avatar
+ 2
Kashish Khan it even works with 2 spaces for all conditions...try and see
26th Oct 2022, 7:47 AM
Riya
Riya - avatar
+ 2
Thank you to both of you
26th Oct 2022, 10:03 AM
Kashish Khan