141k views
0 votes
Python 3.4

given a variable n that is associated with a positive integer and a variable s that is associated with the empty string, write some statements that use a while loop to associate s with a string consisting of exactly 2n asterisks (* . (so if n were associated with 4 then s would, in the end, be associated with "********" .

User Mike Blyth
by
7.1k points

1 Answer

2 votes
i = 0
while( i < ( n * 2 ) ):
s += '*'
i += 1
User Kalitsov
by
7.7k points