Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Homework
#1
I can't find what I did wrong.
def program(a, b, c):
 a = eval(input('Enter value a: '))
 b = eval(input('Enter value b: '))
 c = eval(input('Enter value c: '))
 my_list = list(range(a, b+1))
 if a>b:
    print('0')
 else:
   def power(my_list):
    return[ x**c for x in my_list ]
    my_list = x**c
   print(sum(power(my_list)))
Reply
#2
A couple of things...
For starters, please give thread titles a descriptive title regarding the problem.
Then explain what you want the result of your code to be, and what is the actual result you get. If you get errors post full error traceback message in error tags.
Also the indentation in your code. Blocks are indented by 4 spaces.
Then there are plenty of bad approaches and illogical orders, but we will get to that later.
So first... fix indentation, explain the desired result and actual result, prefereably with exact code you used to test it.
Reply
#3
a=0
b=0
c=0
def program(a, b, c):
 a = eval(input('Enter value a: '))
 b = eval(input('Enter value b: '))
 c = eval(input('Enter value c: '))
 my_list = list(range(a, b+1))
 if a>b:
    print('0')
 else:
   def power(my_list):
    return[ x**c for x in my_list ]
    my_list = x**c
   print(sum(power(my_list)))

program(a,b,c)
Reply
#4
Is my_list = x**c supposed to execute? Because it never will as the code is written.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

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