[Tutor] Creating a Loop
Joel Goldstick
joel.goldstick at gmail.com
Sat Sep 25 16:01:11 EDT 2021
On Sat, Sep 25, 2021 at 5:18 AM dn via Tutor <tutor at python.org> wrote:
>
> On 24/09/2021 13.38, Kaysi Matos via Tutor wrote:
> > I wrote this program to calculate the square root. I am needing to add a loop to be able to enter multiple integers.
> > This is what I have so far.
> > def main():
> > print("This program calculates the square root.")
> > digit = int(input("Enter an integer number: "))
> > square = digit*digit
> > print(f"Square of {digit} is {square}")
> >
> > main()
>
>
you want you program to do this line only once:
> > print("This program calculates the square root.")
so that should not be in your loop
This part of you program you want to do repeatedly:
> > digit = int(input("Enter an integer number: "))
> > square = digit*digit
> > print(f"Square of {digit} is {square}")
> Which type of loop would be best?
>
> --
> Regards,
> =dn
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
--
Joel Goldstick
More information about the Tutor
mailing list