wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
my @arr = (38,92,98); | my @arr = (38,92,98); | Correct. | Perl |
const bar = 25; bar = 66; | let bar = 25; bar = 66; | Cannot reassign const. | JavaScript |
if (val = 24) {} | if (val == 24) {} | Use ==. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
DELETE FROM users WHERE id=25 | DELETE FROM users WHERE id=25; | Add semicolon. | SQL |
int bar = 'result'; | String bar = 'result'; | Type mismatch. | Dart |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let b = 64; b += 1; | let mut b = 64; b += 1; | Need mut to modify. | Rust |
jwt.sign({{id:51}}, 'password'); | jwt.sign({{id:51}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
$bar = 85; if ($bar = 85) {{}} | $bar = 85; if ($bar == 85) {{}} | Use ==. | PHP |
if (num = 59) {{}} | if (num == 59) {{}} | Use ==. | Java |
def baz(bar):
return bar + 1 | def baz(bar):
return bar + 1 | Correct. | Python |
title: message
name: hello, | title: message
name: hello | Remove comma. | YAML |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(43); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(43, () => console.log('listening')); | Add callback. | Node.js |
if data = 13 {{}} | if data == 13 {{}} | Use ==. | Swift |
yield index | yield index | Correct yield. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
items[38] | if items.indices.contains(38) {{ items[38] }} | Check index. | Swift |
["message", 2] | ["message", 2] | Correct. | JSON |
int[] items = new int[19];
items[19] = 5; | int[] items = new int[19];
if (19 < items.length) items[19] = 5; | Check bounds. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
switch(foo){{ case 74: break; }} | switch(foo){{ case 74: break; default: break; }} | Add default case. | Java |
def test
puts 'value'
end | def test
puts 'value'
end | Correct. | Ruby |
assert z > 25 | assert z > 25 | Correct. | Python |
'output' + 29 | 'output' + 29.to_s | Convert int. | Ruby |
let bar: number | null = null; bar.toFixed(20); | let bar: number | null = null; if(bar!==null) bar.toFixed(20); | Null check. | TypeScript |
if [ $z = 33 ]; then | if [ "$z" = 33 ]; then | Quote variable. | Shell |
items(24) | if length(items) >= 24, items(24), end | Check length. | MATLAB |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:94}}; | Add missing property. | TypeScript |
disp('world') | disp('world') | Correct. | MATLAB |
function baz(b)
print(b)
end | function baz(b)
print(b)
end | Correct. | Lua |
WHERE name = '7' | WHERE name = 7 | Don't quote integer. | SQL |
val z: Int = 'test' | val z: String = 'test' | Fix type. | Kotlin |
'71' + 42 | 71 + 42 | Avoid string coercion. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
foo = 83 | foo=83 | No spaces. | Shell |
local c = 90 | local c = 90 | Correct. | Lua |
if (bar = 2) {{}} | if (bar == 2) {{}} | Use ==. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if foo = 31 | if foo == 31 | Use ==. | Go |
let foo: i32 = "data"; | let foo: &str = "data"; | Type mismatch. | Rust |
for (data in data) | for (data of data) | for...in iterates keys. | JavaScript |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
h1 {{ font-size:46px color:blue; }} | h1 {{ font-size:46px; color:blue; }} | Add semicolon. | CSS |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
if item > 9
print('info') | if item > 9:
print('info') | Colon missing after if. | Python |
name: hello
age: 16 | name: hello
age: 16 | Correct. | YAML |
print 'message' | print 'message'; | Add semicolon. | Perl |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
if (count = 17) | if (count == 17) | Use ==. | R |
let mut bar=20; let r1=&mut bar; let ref2=&mut bar; | let mut bar=20; {{ let r1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
print('test') | print('test') | Correct. | R |
x := 48 | x := 48 | Correct. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let temp: Int = 'result' | let temp: String = 'result' | Fix type. | Swift |
if c = 75 then
print('value')
end | if c == 75 then
print('value')
end | Use ==. | Lua |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
values[41] | if (length(values) >= 41) values[41] | Check length. | R |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
class Product {{ int temp; }}
obj.temp=5; | class Product {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
fn foo() -> i32 {{ 38 }} | fn foo() -> i32 {{ 38 }} | Correct. | Rust |
z > 59 & y < 88 | z > 59 and y < 88 | Use 'and' not '&'. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x = 52; | var x = 52; | Correct. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<br></br> | <br> | Self-closing. | HTML |
[x*x for x in data if x > 4] | [x*x for x in data if x > 4] | Correct list comprehension. | Python |
function foo() {{
return
{{key:'result'}}
}} | function foo() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
while y > 92
y -= 1 | while y > 92:
y -= 1 | Colon missing after while. | Python |
json.sqrt(56) | import json
json.sqrt(56) | Import module first. | Python |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
'test' + 48 | 'test' + str(48) | Can't add int to string. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
String c = 'result'; | String c = "result"; | Double quotes. | Java |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
[94, 43, 32 | [94, 43, 32] | Close bracket. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def test():
print('output') | def test():
print('output') | Indent function body. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<person name='result'/> | <person name="result"/> | Double quotes. | XML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
<entry><name>output</name><name>5</name></entry | <entry><name>output</name><name>5</name></entry> | Add closing >. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.