Python Quick Code: High Low Game

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ม.ค. 2025

ความคิดเห็น • 2

  • @markorbik9208
    @markorbik9208 5 หลายเดือนก่อน +1

    in your function, since you are passing userInput as the parameter, couldn't you use "guess == " instead of "userInput == " just curious.

    • @CoachCNY
      @CoachCNY  5 หลายเดือนก่อน

      That would be a more consistent approach, yeah. I didn't even think of it in the moment. I habitually use userInput or readResult as the variable name for things brought in via input() or console.ReadLine(), because I generally validate or typecast the input before writing it to a better-named variable. In this case, I didn't validate the input beyond typecasting it and didn't go the extra step to rename it.
      You're right, though, using guess = int(input("yada rada yada")) to pass into the (guess) parameter would have made more sense. Good catch!