Right now I am trying to make a simple program to separate the javascript links of a website but I'm running into issues with a while loop.
Here would be an example of an input:
001_usa_wool.jpg
002_china_silk.jpg
003_canada_cotton.jpg
004_france_wool.jpg
done
A simplified version of my code with just 3 parts is the following:
def ParseData(input):
data = input.split('_')
d = {}
d['sku'] = data[0]
d['country'] = data[1].capitalize()
d['material'] = data[2].capitalize()
return d
def Sku():
myData = ParseData(input)
sku = myData['sku']
return sku
def Country():
myData = ParseData(input)
country = myData['country']
return country
def Material():
myData = ParseData(input)
material = myData['material']
return material
def Output():
print (Sku()+'\t'+
Country()+'\t'+
Material()+'\t'+
'\n')
Now here is how I tried to read it line by line:
def CleanInput(input):
clean = input.split('.jpg')
count = 0
while (clean[count] != 'done'):
ParseData(clean[count])
Output()
count = count+1
input = input('Enter your data: ')
CleanInput(input)
I believe I am not implementing the while loop correcting since my output is similar to:
001 Usa Wool
001 Usa Wool
001 Usa Wool
for elem in clean:...input()function?001_usa_wool.jpg002_china_silk.jpg003_canada_cotton.jpg004_france_wool.jpgdoneas the entire inputinput) and severe repetition problems.