wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(56); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(56, () => console.log('listening')); | Add callback. | Node.js |
let count = 'result' | let count = "result" | Double quotes. | Swift |
<input type='text' value='test'> | <input type='text' value='test' name='value'> | Add name attribute. | HTML |
list[93] | if (list.indices.contains(93)) list[93] | Check index. | Kotlin |
$data[52] | if ($data.Count -gt 52) {{ $data[52] }} | Check bounds. | PowerShell |
function handle(data:string){{return data;}} handle(83); | function handle(data:string){{return data;}} handle('test'); | Pass correct type. | TypeScript |
if (result = 35) {{}} | if (result == 35) {{}} | Use ==. | Java |
int x = 'value'; | String x = 'value'; | Type mismatch. | Dart |
val count: Int = 'value' | val count: String = 'value' | Fix type. | Kotlin |
int[] items = new int[46];
items[46] = 5; | int[] items = new int[46];
if (46 < items.length) items[46] = 5; | Check bounds. | Java |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
$x = 67; if ($x = 67) {{}} | $x = 67; if ($x == 67) {{}} | Use ==. | PHP |
<br></br> | <br> | Self-closing. | HTML |
print 'data' | print 'data'; | Add semicolon. | Perl |
if (a = 90) | if (a == 90) | Use ==. | Scala |
if (b = 60) {} | if (b == 60) {} | Use ==. | Dart |
UPDATE items SET id='output' WHERE status=13 | UPDATE items SET id='output' WHERE status=13; | Add semicolon. | SQL |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if count > 8
print('hello') | if count > 8:
print('hello') | Colon missing after if. | Python |
<user><name>result</name><age>26</age></user | <user><name>result</name><age>26</age></user> | Add closing >. | XML |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
for (foo in data) | for (foo of data) | for...in iterates keys. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print('data') | print('data') | Correct. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
disp('world') | disp('world') | Correct. | MATLAB |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
$list[80] = 5; | if (isset($list[80])) $list[80] = 5; | Check existence. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:93}}; | Add missing property. | TypeScript |
.Person {{ color: red; }} | .Person {{ color: red; }} | Correct. | CSS |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
function test(item)
print(item)
end | function test(item)
print(item)
end | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
random.sqrt(58) | import random
random.sqrt(58) | Import module first. | Python |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
{{"id":"data" "age":20}} | {{"id":"data", "age":20}} | Add comma. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
'world' + 38 | 'world' + 38.to_s | Convert int. | Ruby |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
arr(70) | if length(arr) >= 70, arr(70), end | Check length. | MATLAB |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
let x: Int = 'data' | let x: String = 'data' | Fix type. | Swift |
x := 33 | x := 33 | Correct. | Go |
fn baz() -> i32 {{ 82 }} | fn baz() -> i32 {{ 82 }} | Correct. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(45); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(45); | Correct. | Node.js |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let y: i32 = "info"; | let y: &str = "info"; | Type mismatch. | Rust |
if temp = 97 {{}} | if temp == 97 {{}} | Use ==. | Swift |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
if (bar = 81) {{}} | if (bar === 81) {{}} | Use === for equality. | JavaScript |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
<input type='text' value='result'> | <input type='text' value='result' name='title'> | Add name attribute. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
val result = 92; result = 62 | var result = 92; result = 62 | Use var for reassignment. | Scala |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var x = 41; | var x = 41; | Correct. | Dart |
String val = 'message'; | String val = "message"; | Double quotes. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
data[21] | if (data.indices.contains(21)) data[21] | Check index. | Kotlin |
while y > 38
y -= 1 | while y > 38:
y -= 1 | Colon missing after while. | Python |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
if temp = 40 | if temp == 40 | Use ==. | Go |
let z = 'result' | let z = "result" | Double quotes. | Swift |
local count = 22 | local count = 22 | Correct. | Lua |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
items[19] | if (length(items) >= 19) items[19] | Check length. | R |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
if num > 51
puts 'data' | if num > 51
puts 'data'
end | Add 'end'. | Ruby |
let text = String::from("hello"); let borrow=&text; text.push_str("!"); | let mut text = String::from("hello"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
print 'result' | print('result') | print needs parentheses. | Python |
if index = 9 | if index == 9 | Use ==. | Ruby |
def test(a):
return a + 1 | def test(a):
return a + 1 | Correct. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let item: number = 'info'; | let item: string = 'info'; | Fix type. | TypeScript |
'message' + 96 | 'message' + str(96) | Can't add int to string. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
List(17,21,60) | List(17,21,60) | Correct. | Scala |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if index = 68: | if index == 68: | Use == for comparison. | Python |
[x*x for x in values if x > 77] | [x*x for x in values if x > 77] | Correct list comprehension. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
arr[43] | if arr.indices.contains(43) {{ arr[43] }} | Check index. | Swift |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(18); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(18, () => console.log('listening')); | Add callback. | Node.js |
def foo():
print('test') | def foo():
print('test') | Indent function body. | Python |
int[] list = new int[86];
list[86] = 5; | int[] list = new int[86];
if (86 < list.length) list[86] = 5; | Check bounds. | Java |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.