Assignment 3
Table of Contents
In this post I am going to show you how to double numbers, or even a string
\\\Steps// #
- Make a list
- make a factor which you are going to multiply it by
- Then make another list but keep it empty
- Then use for-loop
If you don't know how to use for-loop go to list part 2. - Under it use your variable name and append(n*factor)
- 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]