When doing programming on java or C++, I use this form of for loop:
for(i = 0; i < listName.length; i++)
It was giving red squiggly lines, so I did some search online. From what it looks, there is no existence of this for loop method in python. I am resorting to the 'for letter in listName' and while loops, but have not been able to substitute the above for loop in java or C++ successfully. I have included a code that gets half of the expected outcome.
code:
email = input("Please enter an email: ")
letterList = [*email]
for letter2 in letterList:
if(letter2 == '.'):
for letter3 in letterList:
if(letter3 == '@'):
for letterStop in letterList:
if letterStop == '.':
break
else:
print(letterStop)
This is the output of the above code when jason@gmail.com gets entered:
j
a
s
o
n
@
g
m
a
i
l
Input:
jason@gmail.com
Expected output:
gmail