#๐Ÿ”’ can someone help me work through the errors im getting on this code

40 messages ยท Page 1 of 1 (latest)

jaunty duneBOT
#

Hey @stable ridge!

It looks like you pasted Python code without syntax highlighting.

Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
#

@stable ridge

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.

stable ridge
#

this is the first error

plucky yacht
#

when you do print(greater(nums)), you have not defined what nums is

stable ridge
#

nums should be whatever is inputted

plucky yacht
#

yes but you have not defined it

#

when calling the function

#

inside the print

#

oh

#

I see

sudden token
#

The nums inside the function is a different variable from the nums outside the function

plucky yacht
#

you don't really use the nums param

#

it can be removed

#

and then you can just print(greater())

#

also shouldn't else return 0 since the numbers are equal?

stable ridge
#

oh yea

#

can you not get the length of numbers?

plucky yacht
#

you have converted it into an int which doesn't support getting length

#

just get the length first and then convert it

stable ridge
plucky yacht
#

ok there are two ways

#
nums = int(input("input your numbers"))
    
half = len(str(nums))/2```
#

OR

#
nums = input("input your numbers")
half = len(nums)/2
nums = int(nums)```
#

both should work

stable ridge
#

i tried first way

plucky yacht
#

what did you input for numbers?

stable ridge
#

1234

plucky yacht
#

oh

#

you added a space at the front

stable ridge
#

why does tht matter

plucky yacht
#
-int(input("input your numbers"))
+int(input("input your numbers: "))```
#

idk but try this

#

alr I gtg but good luck

stable ridge
#

add negative before int?

jaunty duneBOT
#
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.

#

๐Ÿ”’ can someone help me work through the errors im getting on this code