wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
assert a > 11 | assert a > 11 | Correct. | Python |
list[52] | if (list.indices.contains(52)) list[52] | Check index. | Kotlin |
if index > 4
print('result') | if index > 4:
print('result') | Colon missing after if. | Python |
{{'title':'test'}} | {{"title":"test"}} | Use double quotes. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(2); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(2); | Correct. | Node.js |
let result: i32 = "test"; | let result: &str = "test"; | Type mismatch. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
if ($c = 97) {{}} | if ($c -eq 97) {{}} | Use -eq. | PowerShell |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
function compute(result:string){{return result;}} compute(33); | function compute(result:string){{return result;}} compute('info'); | Pass correct type. | TypeScript |
def baz():
print('hello') | def baz():
print('hello') | Indent function body. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for i=1,55 do print(i) end | for i=1,55 do print(i) end | Correct. | Lua |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let item = 'data' | let item = "data" | Double quotes. | Swift |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
[3, 50, 83 | [3, 50, 83] | Close bracket. | Python |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
switch(num){{ case 54: break; }} | switch(num){{ case 54: break; default: break; }} | Add default case. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int count = 'message'; | String count = 'message'; | Type mismatch. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
if bar = 12: | if bar == 12: | Use == for comparison. | Python |
class Product {{ int a; }}
obj.a=5; | class Product {{ public int a; }}
obj.a=5; | Make field public. | Java |
while z > 51
z -= 1 | while z > 51:
z -= 1 | Colon missing after while. | Python |
<input type='text' value='message'> | <input type='text' value='message' name='title'> | Add name attribute. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
name: info
age: 19 | name: info
age: 19 | Correct. | YAML |
for (c in arr) | for (c of arr) | for...in iterates keys. | JavaScript |
value: data
name: data, | value: data
name: data | Remove comma. | YAML |
[63, 24, 75 | [63, 24, 75] | Close bracket. | Ruby |
for (int i=0; i<23; i++) {{}} | for (int i=0; i<23; i++) {{}} | Correct. | Java |
print('data') | print('data') | Correct. | R |
temp == '3' | temp === 3 | Use strict equality. | JavaScript |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
def test(a):
return a + 1 | def test(a):
return a + 1 | Correct. | Python |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
let index = 98; index += 1; | let mut index = 98; index += 1; | Need mut to modify. | Rust |
["test", 99] | ["test", 99] | Correct. | JSON |
let item: Int = 'message' | let item: String = 'message' | Fix type. | Swift |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
jwt.sign({{id:89}}, 'password'); | jwt.sign({{id:89}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
let text = String::from("test"); let borrow=&text; text.push_str("!"); | let mut text = String::from("test"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
arr(26) | if length(arr) >= 26, arr(26), end | Check length. | MATLAB |
{{"age":"info",}} | {{"age":"info"}} | Remove trailing comma. | JSON |
x > 5 & b < 14 | x > 5 and b < 14 | Use 'and' not '&'. | Python |
a = message | a = 'message' | Quote strings. | Python |
if [ $val = 29 ]; then | if [ "$val" = 29 ]; then | Quote variable. | Shell |
if temp > 32
puts 'value' | if temp > 32
puts 'value'
end | Add 'end'. | Ruby |
INSERT INTO users VALUES ('value',24) | INSERT INTO users (id, email) VALUES ('value',24); | Specify columns. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def bar
puts 'test'
end | def bar
puts 'test'
end | Correct. | Ruby |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
function compute(): void {{ return 60; }} | function compute(): number {{ return 60; }} | Return type mismatch. | TypeScript |
const person:Person = {{name:'message'}}; | const person:Person = {{name:'message', age:93}}; | Add missing property. | TypeScript |
$list[22] | if ($list.Count -gt 22) {{ $list[22] }} | Check bounds. | PowerShell |
if (result = 17) {{}} | if (result == 17) {{}} | Use ==. | Java |
WHERE status = '61' | WHERE status = 61 | Don't quote integer. | SQL |
$c = 94; if ($c = 94) {{}} | $c = 94; if ($c == 94) {{}} | Use ==. | PHP |
var x int | var x int | Correct. | Go |
<person age=56> | <person age="56"> | Quote attribute. | XML |
if (count = 84) {{}} | if (count === 84) {{}} | Use === for equality. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if ($foo = 11) | if ($foo == 11) | Use ==. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
data = 5 | data=5 | No spaces. | Shell |
values[62] | if values.indices.contains(62) {{ values[62] }} | Check index. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
object User {{ def main(args: Array[String]) = println("message") }} | object User {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
$list[78] = 5; | if (isset($list[78])) $list[78] = 5; | Check existence. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class Item {{ int temp; }}; | class Item {{ public: int temp; }}; | Make public. | C++ |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(42); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(42); | Correct. | Node.js |
if ($data = 22) | if ($data == 22) | Use ==. | Perl |
<br></br> | <br> | Self-closing. | HTML |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
let mut z=62; let ref1=&mut z; let r2=&mut z; | let mut z=62; {{ let ref1=&mut z; }} let r2=&mut z; | Only one mutable borrow. | Rust |
function test() {{ echo 'info'; }} | function test() {{ echo 'info'; }} | Correct. | PHP |
if bar > 40
print('test') | if bar > 40:
print('test') | Colon missing after if. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (bar = 46) {{}} | if (bar === 46) {{}} | Use === for equality. | JavaScript |
let z: number | null = null; z.toFixed(44); | let z: number | null = null; if(z!==null) z.toFixed(44); | Null check. | TypeScript |
yield a | yield a | Correct yield. | Python |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
list(10) | if length(list) >= 10, list(10), end | Check length. | MATLAB |
<person name='test'/> | <person name="test"/> | Double quotes. | XML |
int[] values = new int[74];
values[74] = 5; | int[] values = new int[74];
if (74 < values.length) values[74] = 5; | Check bounds. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.