-
Notifications
You must be signed in to change notification settings - Fork 7
Update Part-1-Functions #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,8 +21,22 @@ | |
| # arrayCheck([1, 1, 2, 1, 2, 3]) → True | ||
|
|
||
| def arrayCheck(nums): | ||
| # CODE GOES HERE | ||
|
|
||
| num=[1,2,4,3] | ||
| c=0 | ||
| s=0 | ||
| print(num) | ||
| for i in num: | ||
| if num[s]==1: | ||
| if num[s+1]==2: | ||
| if num[s+2]==3: | ||
| c=1 | ||
| s=s+1 | ||
| if c==1: | ||
| print("true") | ||
| else: | ||
| print("false") | ||
|
|
||
|
|
||
|
|
||
| ##################### | ||
| ## -- PROBLEM 2 -- ## | ||
|
|
@@ -38,7 +52,13 @@ def arrayCheck(nums): | |
| # stringBits('Heeololeo') → 'Hello' | ||
|
|
||
| def stringBits(str): | ||
| # CODE GOES HERE | ||
| str="siddharth" | ||
| s=0 | ||
| n=len(str) | ||
| for i in range(len(str)): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you use "n" variable if your not using it in range!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay |
||
| print(str[s]) | ||
| s=s+2 | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you run the program? It's not correct, there's a possibility of index out of bounds error |
||
|
|
||
|
|
||
| ##################### | ||
|
|
@@ -120,4 +140,8 @@ def fix_teen(n): | |
| # count_evens([1, 3, 5]) → 0 | ||
|
|
||
| def count_evens(nums): | ||
| # CODE GOES HERE | ||
| for i in count_evens | ||
| if count_evens[i]%2==0: | ||
| count=count+1 | ||
|
|
||
| return count | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Program's wrong |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The program is wrong