Python Forum
Help in exercise for loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help in exercise for loop
#13
(Dec-01-2018, 09:46 AM)kais92 Wrote: I'm using python2 because is the one that's using the course that I'm taking, maybe if I used python3 I wouldn't learn the lesson properly. If you tell me that it's better to use python3 anyway I will change it (as I don't understand the differences)
The reason - python2 support ends 1 January 2020. python3 is the future. It is explained in the link I shared (at the bottom)

(Dec-01-2018, 09:46 AM)kais92 Wrote: For the query you gave me the result is not correct as the program is changing the base for the new one in each iteration.
I made a mistake, not to change the range you used. It should be
base = int(input("choose a power base: "))
exp = int(input("choose a power exponent: "))
result = 1
   
for _ in range(exp):
    result *= base
print(result)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Help in exercise for loop - by kais92 - Nov-29-2018, 11:03 PM
RE: Help in exercise for loop - by Larz60+ - Nov-29-2018, 11:21 PM
RE: Help in exercise for loop - by kais92 - Nov-30-2018, 07:32 AM
RE: Help in exercise for loop - by Larz60+ - Nov-30-2018, 08:16 AM
RE: Help in exercise for loop - by buran - Nov-30-2018, 08:32 AM
RE: Help in exercise for loop - by kais92 - Nov-30-2018, 06:18 PM
RE: Help in exercise for loop - by ichabod801 - Nov-30-2018, 06:54 PM
RE: Help in exercise for loop - by kais92 - Nov-30-2018, 11:28 PM
RE: Help in exercise for loop - by ichabod801 - Nov-30-2018, 11:40 PM
RE: Help in exercise for loop - by kais92 - Nov-30-2018, 11:58 PM
RE: Help in exercise for loop - by buran - Dec-01-2018, 08:17 AM
RE: Help in exercise for loop - by kais92 - Dec-01-2018, 09:46 AM
RE: Help in exercise for loop - by buran - Dec-01-2018, 11:00 AM
RE: Help in exercise for loop - by kais92 - Dec-01-2018, 05:16 PM

Forum Jump:

User Panel Messages

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