def rpstr (num, str = "*"): for i in range (1, num + 1): print (str, end = "") str = input ("Enter a string.") num = int (input ("Please enter the number.")) rpstr (num, str) code
Problem: Create a function rpstr (num, str = "*") that repeatedly displays the specified number of strings. The default character string is "*".
Please enter a character string. Yes.
Please enter the number. Five
There is a character string ---
Yes. Yes. Yes. Yes. Yes.
No string ---
I want to display it like this.
Answer # 1
def rpstr (num, str ='*'): print (str * num)
Answer # 2
def rpstr (num, str = "*"):
for i in range (1, num + 1):
print (str, end = "")
str = input ("Enter a string.")
num = int (input ("Please enter the number."))
rpstr (num, str)
- i have a question about basic python problems
- python - about downloading youtube videos by youtube-dl
- python - about hamiltonian neural networks
- python - about write loop to csv
- about python argument and data definition
- python 3x - about downloading anaconda
- python - about the optimum angle of rotation matrix
- python - what i don't understand about yolo9000 (v2)
- about processing to exclude the character string group specified from list in python
- python - about "" "of" "" select === = "" "
- about batch change of file name using python
- about the python speedtest code
- about the implementation of combinations in python
- please tell me about the role of python tag = "mychr"
- about the operation of python's speedtest module (library)
- python, about the fire spread step of forest fire simulation
- python - about x-axis adjustment in matplotlib
- about data plotting in python
- python 3x - about return code of python3 subprocess
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory