Is anything wrong in this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is anything wrong in this code

puts"What is your age?" a = gets.to_i case a when a<19 puts "You are a teenager." when a>19 && a<40 puts "You are a adult." when a>40 puts "You are too old." end

3rd Jan 2018, 3:37 PM
Sanjaykumar Rathod
3 Answers
+ 1
instead of when use if with a semicolon at end of statement
3rd Jan 2018, 5:00 PM
Sasin Nisar 83
Sasin Nisar 83 - avatar
+ 1
if you are python user then use this age=input ("Enter your age:") if a<19: print "you are teenager" if a(20,40): print "you are an adult" if a>40: print "you are too old"
3rd Jan 2018, 5:05 PM
Sasin Nisar 83
Sasin Nisar 83 - avatar
0
As I see it, if you're 19 or 40 you're nothing
8th Oct 2019, 2:53 PM
Hélène VONGUE
Hélène VONGUE - avatar