Please help me in python /lambda and exception | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Please help me in python /lambda and exception

i want from user the input(int) , and if the user input was string (ValueError) i make the user inter again all of this by try: lambda except: please any one help me😊

27th Mar 2020, 7:22 PM
Monzer
17 Answers
+ 6
could be like that age=lambda: int(input(" inter your age")) noinp = True while noinp: try: age() noinp = False except ValueError: print("error inter real age")
28th Mar 2020, 1:36 PM
Oma Falk
Oma Falk - avatar
+ 5
oh Code Crasher you know me right? I am addicted to this kind of questions. Yes.... why....???? to see if it works. Useless like climbing Mount Everest but funny.
28th Mar 2020, 3:47 PM
Oma Falk
Oma Falk - avatar
+ 2
I also like to write oneliner block-monsters once in a while, for the sake of it. When I write 'serious' code, I'll always choose the simplest tool that properly does the job, just as I wouldn't use a butter knife, a scalpel, a dagger and a katana interchangeably.
28th Mar 2020, 5:08 PM
HonFu
HonFu - avatar
+ 1
We can not write the code for you, only assist. Please show us your attempt first!
27th Mar 2020, 7:26 PM
HonFu
HonFu - avatar
+ 1
what the problem here try: age=lambda: int(input(" inter your age")) except ValueError: print("error inter real age") age() age()
27th Mar 2020, 7:30 PM
Monzer
+ 1
thank,s pro😉👍
27th Mar 2020, 8:46 PM
Monzer
+ 1
thank,s bro i,ll do that...
27th Mar 2020, 9:00 PM
Monzer
+ 1
no problem pro... i was think that is better to shaeiring aknowlegement while True: print("Thank you for all😁💖💖")
28th Mar 2020, 5:46 AM
Monzer
+ 1
Code Crasher, that's also the reason I'm *not* typically seen in that sort of question. 'Write a program that does x, but you can't use y, however, instead you have to use magical, popular and overrated language feature z...' I just don't see how this would help anybody in real life. It only comes up as constructed questions of mediocre tutorials. #opinion off This is the way I'd do it basically always: while True: inp = input().strip() if inp.isdigit(): break # turn inp to int and do whatever No try/except or lambda, but why use a machine gun against mosquitos in the first place? #opinion now really off
28th Mar 2020, 4:09 PM
HonFu
HonFu - avatar
0
but i want to use a lambda what,s true for that
27th Mar 2020, 8:47 PM
Monzer
0
age() that calling a lamda and the code was runned
27th Mar 2020, 8:48 PM
Monzer
0
USA 😄
27th Mar 2020, 9:02 PM
Monzer
0
no😁iam speak arabic but i inderstand you as a good
27th Mar 2020, 10:14 PM
Monzer
0
i wil do this idea thank you realy love your help so match😃
27th Mar 2020, 10:16 PM
Monzer
0
what is your name in facebook or give me your phone in whatsapp please😊
27th Mar 2020, 10:17 PM
Monzer
0
oma falk ..yes it,s😍
29th Mar 2020, 7:54 AM
Monzer