Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
while loop typical code
#1
Enter a number and then enter an other number add these numbers together and then ask if they want to add another number if they enter y ask them to enter number and keep add the number unitl the answer is N.

once the loop has been stopped , Display the total.

Thank you in advance.
Well below is my code/

num=int(input("enter a number: "))
total=num
again="y"
while again=="y":
    n=int(input("enter a another number: "))
    total=total+n
    nu=input("do you want to add a another number? (y/n) :  ")
    print("total is....",total)
else:
    print("total is",total)
break
Yoriz write Apr-30-2021, 01:23 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button
Reply


Messages In This Thread
while loop typical code - by codefreak - Apr-30-2021, 12:50 PM
RE: while loop typical code - by Yoriz - Apr-30-2021, 01:32 PM
RE: while loop typical code - by Marbelous - Apr-30-2021, 01:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to convert while loop to for loop in my code? tatahuft 4 880 Dec-21-2024, 07:59 AM
Last Post: snippsat
  Typical beginner needing some help foxter00 1 3,438 May-08-2019, 11:46 PM
Last Post: michalmonday

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020