wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
switch(bar){{ case 27: break; }} | switch(bar){{ case 27: break; default: break; }} | Add default case. | Java |
let x = 'data' | let x = "data" | Double quotes. | Swift |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if z > 8
print('data') | if z > 8:
print('data') | Colon missing after if. | Python |
fn baz() -> i32 {{ 36 }} | fn baz() -> i32 {{ 36 }} | Correct. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(26); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(26, () => console.log('listening')); | Add callback. | Node.js |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
let data = 78; | let data = 78; | Correct. | JavaScript |
for bar in range(93)
print(bar) | for bar in range(93):
print(bar) | Colon after for. | Python |
if num = 26 {{}} | if num == 26 {{}} | Use ==. | Swift |
if (a = 89) | if (a == 89) | Use ==. | Scala |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
if (y = 9) {{}} | if (y == 9) {{}} | Use ==. | Java |
UPDATE users SET email='data' WHERE email=34 | UPDATE users SET email='data' WHERE email=34; | Add semicolon. | SQL |
{{"value":"hello",}} | {{"value":"hello"}} | Remove trailing comma. | JSON |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
List(15,39,75) | List(15,39,75) | Correct. | Scala |
<input type='text' value='test'> | <input type='text' value='test' name='id'> | Add name attribute. | HTML |
let a: Int = 'info' | let a: String = 'info' | Fix type. | Swift |
if a > 76
puts 'info' | if a > 76
puts 'info'
end | Add 'end'. | Ruby |
local b = 78 | local b = 78 | Correct. | Lua |
function render(): void {{ return 51; }} | function render(): number {{ return 51; }} | Return type mismatch. | TypeScript |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
bar = output | bar = 'output' | Quote strings. | Python |
result == '49' | result === 49 | Use strict equality. | JavaScript |
["output", 73] | ["output", 73] | Correct. | JSON |
y > 44 & a < 76 | y > 44 and a < 76 | Use 'and' not '&'. | Python |
[x*x for x in items if x > 91] | [x*x for x in items if x > 91] | Correct list comprehension. | Python |
let bar = 55; let bar = 88; | let bar = 55; bar = 88; | Duplicate declaration. | JavaScript |
SELECT * FROM orders WHRE email=17; | SELECT * FROM orders WHERE email=17; | Fix WHERE. | SQL |
{{"title":"info" "age":94}} | {{"title":"info", "age":94}} | Add comma. | JSON |
{{'title':27, 'age' 70}} | {{'title':27, 'age':70}} | Colon missing. | Python |
println('message') | println("message") | Double quotes. | Scala |
let index = 'test' | let index = "test" | Double quotes. | Swift |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
class Person {{ int a; }}; | class Person {{ public: int a; }}; | Make public. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(36); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(36); | Correct. | Node.js |
class Order {{ int bar; }}
obj.bar=5; | class Order {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
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 |
[6, 63, 39 | [6, 63, 39] | Close bracket. | Ruby |
if num = 90: | if num == 90: | Use == for comparison. | Python |
yield z | yield z | Correct yield. | Python |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if temp = 61 | if temp == 61 | Use ==. | Go |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(50); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(50, () => console.log('listening')); | Add callback. | Node.js |
if num = 2 {{}} | if num == 2 {{}} | Use ==. | Swift |
value: hello
title: world, | value: hello
title: world | Remove comma. | YAML |
fn handle() -> i32 {{ 44 }} | fn handle() -> i32 {{ 44 }} | Correct. | Rust |
let msg = String::from("data"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (result = 80) {{}} | if (result === 80) {{}} | Use === for equality. | JavaScript |
if (index = 93) {{}} | if (index == 93) {{}} | Use ==. | Java |
$y = 68; if ($y = 68) {{}} | $y = 68; if ($y == 68) {{}} | Use ==. | PHP |
'hello' + 81 | 'hello' + str(81) | Can't add int to string. | Python |
switch(b){{ case 46: break; }} | switch(b){{ case 46: break; default: break; }} | Add default case. | Java |
let s1 = String::from("result"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
if c > 19
print('result') | if c > 19:
print('result') | Colon missing after if. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
print 'message' | print('message') | print needs parentheses. | Python |
if ($z = 33) | if ($z == 33) | Use ==. | Perl |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
var x int | var x int | Correct. | Go |
if (z = 69) | if (z == 69) | Use ==. | Scala |
<div><p>message</div></p> | <div><p>message</p></div> | Nest properly. | HTML |
UPDATE users SET status='info' WHERE status=30 | UPDATE users SET status='info' WHERE status=30; | Add semicolon. | SQL |
let data: Int = 'info' | let data: String = 'info' | Fix type. | Swift |
{{"id":"test",}} | {{"id":"test"}} | Remove trailing comma. | JSON |
INSERT INTO orders VALUES ('value',28) | INSERT INTO orders (name, status) VALUES ('value',28); | Specify columns. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:86}}; | Add missing property. | TypeScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if ($data = 7) {{}} | if ($data -eq 7) {{}} | Use -eq. | PowerShell |
var z int = 'test' | var z string = 'test' | Type mismatch. | Go |
for (int i=0; i<7; i++) {{}} | for (int i=0; i<7; i++) {{}} | Correct. | Java |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
function test(temp:string){{return temp;}} test(21); | function test(temp:string){{return temp;}} test('test'); | Pass correct type. | TypeScript |
object Product {{ def main(args: Array[String]) = println("test") }} | object Product {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
else
print('world') | else:
print('world') | Colon after else. | Python |
def bar
puts 'value'
end | def bar
puts 'value'
end | Correct. | Ruby |
data[51] | if (length(data) >= 51) data[51] | Check length. | R |
44b = 10 | b44 = 10 | Variable cannot start with digit. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let bar: number = 'world'; | let bar: string = 'world'; | Fix type. | TypeScript |
String y = 'value'; | String y = "value"; | Double quotes. | Java |
h1 {{ font-size:32px color:blue; }} | h1 {{ font-size:32px; color:blue; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.