Advertisement
tabnation

nim if elif else

Apr 19th, 2022
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #nim c -r --verbosity:0 ifelse.nim
  2.  
  3. import strutils, random
  4.  
  5. randomize()
  6. let answer = rand(10) #let wont let var be change
  7. while true:
  8. echo "I have a number from 1 to 10, what is it? "
  9. let guess = parseInt(stdin.readLine)
  10.  
  11. if guess < answer:
  12. echo "Too low, try again"
  13. elif guess > answer:
  14. echo "Too high, try again"
  15. else:
  16. echo "Correct!"
  17. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement