Skip to main content
  1. Posts/

Assignment 3

·179 words·1 min
Table of Contents

In this post I am going to show you how to double numbers, or even a string

\\\Steps// #

  1. Make a list
  2. make a factor which you are going to multiply it by
  3. Then make another list but keep it empty
  4. Then use for-loop If you don't know how to use for-loop go to list part 2.
  5. Under it use your variable name and append(n*factor)
  6. Then all you have to do is print(whatever you named that empty variable)

Here is something it should look like:

num_list = [1, 2, 5, 6]
factor = 3
output = []
for n in num_list:
      output.append(n*factor)
print(output)

Output: This is what it will print out

[3, 6, 15, 18]

\\\Extra// #

So if you want to do something extra come here so instead of print output we print(‘This is the output:’ ) then we use f-string and use the squiggly brace and type whatever empty list you named and your done. Here is what it should look like

print(f'This is the output: ')

print(f"{output}") 

Output: This is the output:

[3, 6, 15, 18]