starting to get used to asking more advanced programmers instead of wasting hours looking for a solution and coming up with nothing.
I have a working code to find prime numbers. Code asks for user to select a number and returns the prime numbers untill user input. However I am trying to reutrn the user input as N.
def calculate_n_prime():
n_numbers = int(input("How many prime numbers would you like to see? "))
for num in range(2, n_numbers):
if num > 1:
for i in range(2, num):
if (num % i) == 0:
break
else:
print(num, end="-")
if __name__ == "__main__":
calculate_n_prime()
Current code returns = [2,3,5,7]
I want a code that returns = [2,3,5,7,11,13,17,19,23,29]
Note - I understand the range function is an issue since it iterates until that number. However without it my code wont work and I didnt really know how to explain my issue. I originally thought the question I was given was to ask for two inputs (first and last #) and return all prime numbers inbetween. Now I am trying to correct my code for the question at hand (Get N prime #'s) Btw, i have tried changing my code numerous times and have been searching and reading isnce yesterday, however since I am so new to the basics it is very difficult to really understand the logic of what i am reading if my code is not the same. (I am in a Trainee program where I am learning software development and am only 2 months in. I began not knowing what a string was. I hope everyone reading this understands that I have tried other solutions, however, I am just having beginner issues and hopefully will begin to progress by asking questions to code I made)
I know we all dont know each other, but I am very shy and hesitate to ask questions because they seem too basic.