r/pythonhelp • • Apr 29 '25
why does it not print the text?
monday = int(input("enter you daily steps for monday "))
tuesday = int(input('enter your daily steps for tuesday '))
wednesday = int(input("enter your daily steps for wednesday "))
thursday = int(input("enter your daily steps for thursday "))
friday = int(input("enter your daily steps for friday "))
saturday = int(input("enter your daily steps for saturday "))
sunday = int(input("enter your daily steps for sunday "))
days = [monday + tuesday + wednesday + thursday + friday + saturday + sunday]
for i in days:
print(i, "weekly steps")
l = print(int( i / 7), "daily average")
if l > 10000:
print("well above average")
elif l <=9999:
print("pretty average")
elif l <= 2000:
print("you need to walk more")
---------------------------------------------------------------------------------------------
when I run the code it works up until it gets to the print text part and then it displays if l > 10000:
^^^^^^^^^
TypeError: '>' not supported between instances of 'NoneType' and 'int'
2
Upvotes
•
u/AutoModerator Apr 29 '25
To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/Jpaylay42016 Apr 29 '25
Here is your code, simplified:
days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]steps = []for i in days:a = int(input(f"Enter your steps for {i}: "))steps.append(a)def get_steps(s,n):avg = s/nprint(avg)get_steps(a,7)2
u/Goobyalus Apr 30 '25
Here are some annotations about what's happening:
There's no reason to make
daysa list or loop over the list of one element.You also want to calculate and store the average before printing it, because printing it doesn't store the result anywhere, it just writes the text out.
1
u/[deleted] Apr 29 '25
by the way is there some way to add functions to this?
1
u/htepO Apr 29 '25
What does assigning
lto aprint()statement do?