Python Forum
Use range to add char. to empty string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use range to add char. to empty string
#5
In general, the problem statement

Quote:Then using range, write code such that when your code is run, lett has 7 b’s ("bbbbbbb").

slightly confuses me. A minimal solution would be
lett = ''
range
lett = 'b' * 7
We've used range function and assigned desired result to the lett variable.
Formally, everything is done. No one requires us to use for-loop.
Reply


Messages In This Thread
RE: Use range to add char. to empty string - by scidam - Apr-15-2019, 11:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with stripping special char and spaces mumstead 7 2,775 Jun-11-2020, 05:44 AM
Last Post: Yoriz
  String index out of range felie04 2 5,526 Aug-17-2018, 11:18 PM
Last Post: felie04
  string index out of range cusick11 9 15,109 Mar-03-2017, 11:45 PM
Last Post: ichabod801
  Invalid syntax: string index out of range darkreaper1959 6 6,152 Jan-22-2017, 06:24 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020