python-course icon indicating copy to clipboard operation
python-course copied to clipboard

lesson 13 f - strings

Open langerking opened this issue 2 years ago • 1 comments

Really enjoying your course. So much packed into every lesson, really well done!

Just wanted to comment that when you change the concatenated strings in rps5.py to f-strings I think it should be noted that you can further simplify: f string allows multiple datatypes so several castings to different variable types can be omitted:

ln 26 player = int(playerchoice) and computer = int(computerchoice)

the print statements on ln 33, 34 can be shortened:

from: print("\nYou chose {str(RPS(player)).replace('RPS.', '').title()}") to: print(f"\nYou chose {playerchoice.replace('RPS.', '').title()}")

also print statements ln 62, 63 & 64 do not need the str constructor: print("\nGame count: {str(game_count)) >> print(f"\nGame count: {game_count}")

langerking avatar Sep 26 '23 19:09 langerking

I was wrong about modifying the code referencing the RPS class. Need to leave the str constructor in there or else the names (ROCK....) won't get retrieved and printed.

langerking avatar Sep 28 '23 13:09 langerking