python – Books or resources for solving university programming questions

It’s my first semester as a CSE student. I have a course that teaches Python. I understand basics. But when it comes to solving questions like the ones shared, I literally can’t do anything. Is it from a lack of practice? or did I miss some kind of manual. Can anyone recommend me any book or website that teaches how to approach or solve these kinds of questions. I’m getting very demotivated from constant failure.

Don’t worry. These are questions from my previous quizes.

π—€π˜‚π—²π˜€π˜π—Άπ—Όπ—» 1:
Write a python program that will run a loop until the user gives the input 
β€œSTOP”. Then based on the user inputs print the pattern as shown in the 
examples. The output should be printed AFTER the END OF GIVING INPUT.
(You are not allowed to use String multiplication for this task)
================================

Sample Input 1:
a
b
c
d
STOP

Sample Output 1:
aaaa
bbb
cc
d

Explanation of Output 1:
Here use gives 4 inputs before β€œSTOP” so the output consists of 4 lines. 
The first input was β€˜a’ so the program prints β€˜aaaa’ in the first line. The 
second input was β€˜b’ so the program prints β€˜bbb’ in the second line. The 
third input was β€˜c’ so the program prints β€˜cc’ in the third line. The 
fourth input was β€˜d’ so the program prints β€˜d’.
================================
Sample Input 2:
a
b
c
STOP

Sample Output 2:
aaa
bb
c

Explanation of Output 2:
Here use gives 3 inputs before β€œSTOP” so the output consists of 3 lines. 
The first input was β€˜a’ so the program prints β€˜aaa’ in the first line. The 
second input was β€˜b’ so the program prints β€˜bb’ in the second line. The 
third input was β€˜c’ so the program prints β€˜c’ in the third line.
π—€π˜‚π—²π˜€π˜π—Άπ—Όπ—» 2:
Take a word and a single character as user inputs. Print β€œYes” if and only 
if the word starts and ends with the character and the character is not 
present anywhere in the rest of the word. Otherwise, print β€œNo”.

(You are not allowed to use any built-in function including count() for 
string except len(). Cannot use string slicing)
=============================================================
Sample Input 1:
hello
o
Sample Output 1:
No
Explanation 1:
The word doesn’t start with β€˜o’.
=============================================================
Sample Input 2:
lol
l
Sample Output 2:
Yes
Explanation 2:
The word starts and ends with β€˜l’. Also, β€˜l’ doesn’t appear anywhere in the 
rest of the substring.
  =============================================================
Sample Input 3:
astrazeneca
a
Sample Output 3:
No
Explanation 3:
The word starts and ends with β€˜a’ but β€˜a’ is present in the substring 
β€œstrazenec”.