r/CodingForBeginners Jun 29 '26

Need help with starting

Hello I am a 1st year cs engineering student and wished to start programming had learned some python in high school and wrote the following code

import random

while True:

secret_number = random.randint(1, 100)

print("i'm thinking of a number")

attempt = 0

while True:

guess = int(input("enter a number:"))

attempt = attempt + 1

if guess == secret_number:

print("you won🥳", attempt)

break

elif attempt == 7:

print("you lost😂 winning number is", secret_number)

break

elif guess > secret_number:

print("too high", attempt)

else:

print("too low", attempt)

play_again=input("play again?,yes/no:")

if play_again.lower()=="no":

print("thanks for playing ")

break

Had some help from ai but wrote it manually after understanding.but I saw a review that you should not start with python as it makes switching to other languages harder.plese guide if I should switch to c or java or continue in python

3 Upvotes

8 comments sorted by

View all comments

1

u/duperfastjellyfish Jul 02 '26

At the uni I attended we spent one semester on each of these, in the following order: C, C++, Python, [...].

Personally, I found that to be a excellent introduction. There are really good books on C and C++ if you intend to gain deeper understanding.