Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lesson 13 f - strings #3

Open
langerking opened this issue Sep 26, 2023 · 1 comment
Open

lesson 13 f - strings #3

langerking opened this issue Sep 26, 2023 · 1 comment

Comments

@langerking
Copy link

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant