print ("I will output a multiple of 7 from 1 to 100")
a = 0
def seven_cal (*args):
global a
result = [ ]
for x in range(1,101):
a = 1
a = a + 1
if a %7 == 0:
result.append(a)
return result
print(result)
seven_cal()
Now, the value of none is constantly displayed here. What's the problem?
python
Given the state of the code, I've just started studying PythonRather than that, I needed something like this, so I roughly found it and made it.
Based on the code, it looks like you've compiled what you've looked up here and there.
You've compiled a code that doesn't fit at all.
If you've studied coding a little bit, you've organized the code in a way that you wouldn't have done, and if you want to solve it yourself, you'd better find something that can help you, whether it's on the Internet or in a book.
If you simply want to print that number every time you get a multiple of 7, the code should consist of:
print ("I will output a multiple of 7 from 1 to 100")
def seven_cal ():
for a in range(1,101):
if a %7 == 0:
print(a)
seven_cal()
>> 7
14
21
28
35
42
49
56
63
70
77
84
91
98
If you want to output a composite of the results of finding a multiple of 7 in the function, construct the code in the following way:
print ("I will output a multiple of 7 from 1 to 100")
def seven_cal ():
result = []
for a in range(1,101):
if a %7 == 0:
result.append(a)
return result
b = seven_cal()
print(b)
>> [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
562 Who developed the "avformat-59.dll" that comes with FFmpeg?
589 GDB gets version error when attempting to debug with the Presense SDK (IDE)
566 Understanding How to Configure Google API Key
854 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
563 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.