0

I need to iterate in a function for 3 accounts and print each account[i]

months_subscribed = input() acct = ["Account 1", "Account 2", "Account 3"] account = [] def summary_months_sub(): # acct = ["Account 1", "Account 2", "Account 3"] mostEarned = 0.0 combined = 0.0 month_subscribed = int(input()) if month_subscribed < 3: a1_month2_sub = month_subscribed * 7 else: remain = month_subscribed % 3 a1_month2_sub = month_subscribed * 6 + remain a1_ad_free = float(input()) * 2 a1_vod = float(input()) * 27.99 a1_vod = a1_vod.__round__(2) a1_total_summary = a1_month2_sub + a1_ad_free + a1_vod combined += a1_total_summary a1_premium = a1_ad_free + a1_vod account1 = combined a2_months_sub = a1_month2_sub a2_ad_sub = a1_ad_free a2_vod = a1_vod.__round__(2) a3_months_sub = a1_month2_sub a3_ad_sub = a1_ad_free a3_vod = a1_vod.__round__(2) months = [a1_month2_sub, a2_months_sub, a3_months_sub] ads = [a2_ad_sub, a2_ad_sub, a3_ad_sub] vods = [a1_vod, a2_vod, a3_vod] for i in range(3): print(f'{acct[i]} made

#x27;,a1_total_summary.__round__(2), 'total') print(f'>>>
#x27;{months[i]},'from monthly subscription fees') print(f'>>>
#x27;,{ads[i]}, 'from Ad-free upgrades') print(f'>>>
#x27;,{vods[i]}, 'from Video on Demand purchases') print() summary_months_sub() #i need the i printed different accounts. but i need to iterate in the function. tests wont let me #iterate out of the function

25th Jan 2022, 5:36 PM
Esther McAngus
5 Respostas
+ 1
There is a little + on the right side
25th Jan 2022, 5:56 PM
Lisa
Lisa - avatar
+ 3
Multiple functions can be created
25th Jan 2022, 10:42 PM
SoloProg
SoloProg - avatar
+ 1
Okay, I don't fully understand yet what it is supposed to do but here some things: * check your f-strings, they are like: f'hello {x}' * pass accounts and input (months) as arguments to the function (instead of writing them inside of the function)
25th Jan 2022, 6:02 PM
Lisa
Lisa - avatar
0
Please put your code in a script on sololearn playground and link it. Tag the relevant programming language.
25th Jan 2022, 5:42 PM
Lisa
Lisa - avatar
25th Jan 2022, 5:55 PM
Esther McAngus