Python Forum
A function taking in parameter int and str
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A function taking in parameter int and str
#1
Hello everyone,

I am very new in coding and in Python so my question is probably stupid but nevertheless i'm searching on internet for a solution since hours and i do not find anything that could help me. (I use python 3.7)

I have an this exercice : "Implement a symbol_line function taking an integer N and a character as a parameter and displaying N times the character on the same line"

I write :
def ligne_de_symboles (N, "A"):
    print (N*"A")
But there is a "SyntaxError: invalid syntax" on the "A" so that i can't run my function.
Is there a way to do a function with a str "A" as a parameter ?

English is not my native language and i do not really know what i am talking about but i hope that my question is comprehensible.

Thank you by advance
Reply
#2
Parameters have to be variable names, perhaps with an equals and then a default value.

Simple solution: remove all the quotes in the code you posted.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  parameter in function being involuntarily converted to str?? juliabrushett 8 5,896 Jul-03-2018, 04:23 PM
Last Post: gruntfutuk
  Recursive function with a parameter MOH 0 2,639 Apr-30-2018, 09:39 PM
Last Post: MOH
  function with radius as a parameter that returns area of a circle taydeal20 4 8,467 Feb-07-2018, 03:33 PM
Last Post: buran

Forum Jump:

User Panel Messages

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