#๐Ÿ”’ some basic error im not able to sort

19 messages ยท Page 1 of 1 (latest)

fresh cipherBOT
#

Hey @slate verge!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes 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.
#

@slate verge

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.

opaque hull
#

input() always returns a string, you have to convert it to a number before you can perform arithmetic operations on it

use int() or float()

slate verge
dim slate
slate verge
#

while not ipb.isdigit():
^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'isdigit'

vague plinth
#

if I were you, I'd not check each digit individually. This is what Akex means by "try except it"

#
def get_int(prompt):
    while True:
        try:
            return int(input(prompt))
        except ValueError as e:
            print(f"{e}; please try again")


ipb = get_int("please enter your inital principal balance : ")

print("ipb stored")

ir = get_int("please enter the inrest rate % : ")

print("ir stored")

time = get_int("please enter time period in years : ")

print("time stored")

final = ipb * pow((1 + ir / 100), time)

print(f" your final output is {final}")
#

tested, works

slate verge
#

yeah the thing is im a beginer i dont know what def and the other things are

#

thanks for the help tho

vague plinth
#

time to learn, then ๐Ÿ™‚

slate verge
#

yea

vague plinth
#

when you find yourself writing the same code over and over -- as you've done -- it's time to write a function instead

#

then you only have to write that bit of code once.

slate verge
#

appreciate your help thank you

fresh cipherBOT
#
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.