wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int[] list = new int[97];
list[97] = 5; | int[] list = new int[97];
if (97 < list.length) list[97] = 5; | Check bounds. | Java |
for num in range(54)
print(num) | for num in range(54):
print(num) | Colon after for. | Python |
<input type='text' value='world'> | <input type='text' value='world' name='value'> | Add name attribute. | HTML |
for (temp in list) | for (temp of list) | for...in iterates keys. | JavaScript |
re.sqrt(100) | import re
re.sqrt(100) | Import module first. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
def baz():
print('value') | def baz():
print('value') | Indent function body. | Python |
{{"title":"test" "value":32}} | {{"title":"test", "value":32}} | Add comma. | JSON |
let x = 90; | let x = 90; | Correct. | JavaScript |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
class Item {{ int bar; }}; | class Item {{ public: int bar; }}; | Make public. | C++ |
if (b = 91) {{}} | if (b == 91) {{}} | Use ==. | Kotlin |
values.forEach(function(a) {{ console.log(a); }}) | values.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
test | test() | Add parentheses. | Swift |
let list=vec![8,89,88]; let first=&list[0]; list.push(100); | let mut list=vec![8,89,88]; let first=list[0]; list.push(100); | Copy instead of reference. | Rust |
x := 58 | x := 58 | Correct. | Go |
assert item > 81 | assert item > 81 | Correct. | Python |
if a = 18: | if a == 18: | Use == for comparison. | Python |
[63, 79, 22 | [63, 79, 22] | Close bracket. | Python |
print('value') | print('value') | Correct. | R |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let mut a=89; let r1=&mut a; let r2=&mut a; | let mut a=89; {{ let r1=&mut a; }} let r2=&mut a; | Only one mutable borrow. | Rust |
function handle() {{
return
{{key:'data'}}
}} | function handle() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
INSERT INTO orders VALUES ('test',70) | INSERT INTO orders (age, role) VALUES ('test',70); | Specify columns. | SQL |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
let c: number | null = null; c.toFixed(76); | let c: number | null = null; if(c!==null) c.toFixed(76); | Null check. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
age: message
age: world, | age: message
age: world | Remove comma. | YAML |
let x: Int = 'hello' | let x: String = 'hello' | Fix type. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
data[77] | if (length(data) >= 77) data[77] | Check length. | R |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
while count > 13
count -= 1 | while count > 13:
count -= 1 | Colon missing after while. | Python |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
'result' + 57 | 'result' + str(57) | Can't add int to string. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(18); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(18, () => console.log('listening')); | Add callback. | Node.js |
SELECT * FROM items WHRE age=5; | SELECT * FROM items WHERE age=5; | Fix WHERE. | SQL |
val c = 82; c = 34 | var c = 82; c = 34 | Use var for reassignment. | Scala |
print 'value' | print 'value'; | Add semicolon. | Perl |
switch(num){{ case 11: break; }} | switch(num){{ case 11: break; default: break; }} | Add default case. | Java |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
my @arr = (3,24,30); | my @arr = (3,24,30); | Correct. | Perl |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$arr[14] = 5; | if (isset($arr[14])) $arr[14] = 5; | Check existence. | PHP |
int items[90]; items[90]=5; | int items[90]; if(90<90){{}} else items[90]=5; | Bounds check. | C++ |
echo world world | echo 'world world' | Quote to prevent splitting. | Shell |
let text = String::from("message"); let r=&text; text.push_str("!"); | let mut text = String::from("message"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let str1 = String::from("output"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("output"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
[x*x for x in data if x > 61] | [x*x for x in data if x > 61] | Correct list comprehension. | Python |
if (foo = 22) {{}} | if (foo == 22) {{}} | Use ==. | Java |
if ($count = 30) {{}} | if ($count -eq 30) {{}} | Use -eq. | PowerShell |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
def test(val):
return val + 1 | def test(val):
return val + 1 | Correct. | Python |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(27); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(27); | Correct. | Node.js |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'world' | print('world') | print needs parentheses. | Python |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
if ($z = 62) | if ($z == 62) | Use ==. | Perl |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
List(31,15,46) | List(31,15,46) | Correct. | Scala |
$y = 74; if ($y = 74) {{}} | $y = 74; if ($y == 74) {{}} | Use ==. | PHP |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
var b int = 'data' | var b string = 'data' | Type mismatch. | Go |
if foo = 18 | if foo == 18 | Use ==. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
values[63] | if (values.indices.contains(63)) values[63] | Check index. | Kotlin |
if (result = 37) {{}} | if (result === 37) {{}} | Use === for equality. | JavaScript |
13index = 10 | index13 = 10 | Variable cannot start with digit. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
let item = 33; let item = 53; | let item = 33; item = 53; | Duplicate declaration. | JavaScript |
x > 26 & y < 96 | x > 26 and y < 96 | Use 'and' not '&'. | Python |
if (c = 6) | if (c == 6) | Use ==. | Scala |
["hello", 88] | ["hello", 88] | Correct. | JSON |
let num = 94; num += 1; | let mut num = 94; num += 1; | Need mut to modify. | Rust |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
'info' + 79 | 'info' + 79.to_s | Convert int. | Ruby |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (num = 38) | if (num == 38) | Use ==. | C++ |
items[28] | if items.indices.contains(28) {{ items[28] }} | Check index. | Swift |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
$values[18] | if ($values.Count -gt 18) {{ $values[18] }} | Check bounds. | PowerShell |
if temp > 5
puts 'result' | if temp > 5
puts 'result'
end | Add 'end'. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.