Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Casting from str to int
#5
If you got it working then you should have time to consider some other aspects of your code:

- use naming conventions set in PEP8 (Function and Variable Names)
- on row #13 you calculate sum. On next line you calculate it again instead of using already calculated value.
- instead of repeating rows #3-7 and then putting variables into list you can do it in one step (note that I omitted datatype conversion problem as it is already solved):
 
>>> [input(f'Enter mark {i+1}: ') for i in range(5)]
Enter mark 1: 1
Enter mark 2: 2
Enter mark 3: 3
Enter mark 4: 4
Enter mark 5: 5
['1', '2', '3', '4', '5']
buran likes this post
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Casting from str to int - by aztrav - Oct-13-2020, 05:20 AM
RE: Casting from str to int - by buran - Oct-13-2020, 05:27 AM
RE: Casting from str to int - by aztrav - Oct-13-2020, 06:09 AM
RE: Casting from str to int - by aztrav - Oct-13-2020, 06:17 AM
RE: Casting from str to int - by perfringo - Oct-13-2020, 09:10 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020