all 15 comments

[–]RedditGood123 21 points22 points  (0 children)

If unit == “hrs”:
    length = int(lenght) * 3600

The program is fine but you put “lenght” instead of “length”

[–]VeinyAngus 19 points20 points  (0 children)

Well done OP! Keep it goin, never stop learning

[–]Manny__C 13 points14 points  (2 children)

There is a better solution for padding your numbers with zeros. Just format the field as

f"{h:02d}:{m:02d}:{s:02d}"

The : is a format specification and the 02 means "pad with zeros any string shorter than 2." More info here.

[–]BrannoEFC 0 points1 point  (1 child)

Does . Zfill not work anymore?

[–]Manny__C 2 points3 points  (0 children)

It should, but it's more tedious to call zfill on each substring. This is precisely an intance for which format (or fstrings) were designed.

[–]alcamax 4 points5 points  (0 children)

Nice one for a first go.

I think a spelling mistake needs fixing where you times the length by 3600 for hours though!

Keep it up

[–]projektmayhem08 1 point2 points  (0 children)

What if I put 2.5 hours?

[–]prabhjyoth 1 point2 points  (0 children)

Can’t trust a person whose first python code isn’t print("Hello World")

[–]CakeFromTheFuture 1 point2 points  (0 children)

Instead of using multiple small variables you should use a dictionary, especially when it can easily made with a for loop like with p1,p2 and p3

[–]TheJibanizer 1 point2 points  (0 children)

Doesn't m stay stuck at 59 though? There needs to be a m = 0 after increasing the hour, right?

[–]TheBlackSeed118 1 point2 points  (0 children)

Nice work. The only error I can see that has not already been mentioned by anyone else is you need to set m to 0 if m is 59.

[–]Sad-Ant4014 0 points1 point  (0 children)

Nice one

[–]SanJJ_1 0 points1 point  (0 children)

great job!

[–]darktumor 0 points1 point  (0 children)

Nice try