The program
Edit anything and press Run. The output below was produced by running this exact code.
Expected output
Press Run to try it
=== 🏏 MATCH FINAL OVER COMMENTARY 🏏 ===Target: 18 runs required in 6 balls! Ball 1 : ⚡ GAP MAIN MARA! FOUR BOUNDARY! 💥 (+4)Ball 2 : 🚀 SHOTTT! Gend stadium ke bahar! SIXER! 🎉 (+6)Ball 3 : 🏃 Single bhag liya. (+ 1 )Ball 4 : 🤦♂️ DOT BALL! Pressure building up! (0)Ball 5 : 🚀 SHOTTT! Gend stadium ke bahar! SIXER! 🎉 (+6)Ball 6 : 🏃 Single bhag liya. (+ 2 ) 🏏 Final Score in Last Over: 19 runs!🏆 UNBELIEVABLE WIN! Match jeet gaye bhai! Confetti time! 🎉🥳🔥
How it works
Each ball's runs are stored in a list. The loop counts balls from 1 to 6 and reads runs_per_ball[ball - 1], because the first ball is at position 0.
total_runs = total_runs + shot keeps a running total, and a warna agar chain prints different commentary for a six, a four, a dot ball or anything else. After the loop, one more agar decides whether the target of 18 was reached.