#๐Ÿ”’ Bugs/general confusion

29 messages ยท Page 1 of 1 (latest)

north summitBOT
#

@blissful hatch

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

blissful hatch
#

Problem with if statement within if statement as well as the len(varriable) won't count a int in the string if its single digit

kind ledge
#

show us your code

blissful hatch
#

did that do it?

kind ledge
#

input always returns a string, so if weeks == 1 will never be true

#

you need to convert it into an int using int

#

weeks = int(input("How many weeks did you work?"))

blissful hatch
#

gotcha thats super helpful

#

what about the line 50

#

and the single digit number

#

is because I also need to change the numbers into an int?

kind ledge
#

well, what does it mean to take the len of a number

blissful hatch
#

is it the number of digits

#

it gives u an int value based on how many strings there are in the varriable yeah

#

well items I think like strings bool and int

kind ledge
#

if you want to get the number of digits in a number, the simplest way is to convert it to a str and take its len

#

!e

x = 538
print("number of digits is:", len(str(x)))
north summitBOT
blissful hatch
#

I want the amount of int that were inputed. so if I inputed 10, 5, 60, 4 it should show up as 4 I thought but instead it is showing up as 2

kind ledge
#

you're confusing your variables...

#

total_hours = input("What was the total number of hours worked in one week?")
total hours is each individual input, not the list of all inputs

blissful hatch
#

oh biscuits

#

if you inputed total hours as 12 though and did the len command it would show up as 1 yes?

kind ledge
#

len on what

blissful hatch
#

I think im understanding. So my numbers are they going into the variables as int rather than strings hence why the len command is counting them

kind ledge
#

I don't think that's quite the problem...

north summitBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.