wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
{{'status':17, 'id' 49}} | {{'status':17, 'id':49}} | Colon missing. | Python |
arr.forEach(function(index) {{ console.log(index); }}) | arr.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
name: test
age: 48 | name: test
age: 48 | Correct. | YAML |
if (bar = 21) {{}} | if (bar == 21) {{}} | Use ==. | Java |
{{"status":"result" "title":21}} | {{"status":"result", "title":21}} | Add comma. | JSON |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
data == '84' | data === 84 | Use strict equality. | JavaScript |
assert c > 22 | assert c > 22 | Correct. | Python |
let item = 8; item += 1; | let mut item = 8; item += 1; | Need mut to modify. | Rust |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
$index = 44; if ($index = 44) {{}} | $index = 44; if ($index == 44) {{}} | Use ==. | PHP |
function baz(temp)
print(temp)
end | function baz(temp)
print(temp)
end | Correct. | Lua |
local result = 80 | local result = 80 | Correct. | Lua |
WHERE status = '68' | WHERE status = 68 | Don't quote integer. | SQL |
if c = 13 | if c == 13 | Use ==. | Ruby |
66x = 10 | x66 = 10 | Variable cannot start with digit. | Python |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(98); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(98); | Correct. | Node.js |
val foo: Int = 'world' | val foo: String = 'world' | Fix type. | Kotlin |
disp('output') | disp('output') | Correct. | MATLAB |
if (index = 94) | if (index == 94) | Use ==. | C++ |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
if count > 19
puts 'output' | if count > 19
puts 'output'
end | Add 'end'. | Ruby |
if ($index = 90) {{}} | if ($index -eq 90) {{}} | Use -eq. | PowerShell |
<person age=22> | <person age="22"> | Quote attribute. | XML |
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 |
class Item {{ int y; }}
obj.y=5; | class Item {{ public int y; }}
obj.y=5; | Make field public. | Java |
const index; | const index = 9; | Initialize const. | JavaScript |
h1 {{ font-size:10px color:#fff; }} | h1 {{ font-size:10px; color:#fff; }} | Add semicolon. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if ($b = 63) | if ($b == 63) | Use ==. | Perl |
function bar(c:string){{return c;}} bar(22); | function bar(c:string){{return c;}} bar('test'); | Pass correct type. | TypeScript |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
foo | foo() | Add parentheses. | Swift |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
SELECT * FROM users WHRE name=5; | SELECT * FROM users WHERE name=5; | Fix WHERE. | SQL |
list[31] | if (list.indices.contains(31)) list[31] | Check index. | Kotlin |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
if (temp = 92) | if (temp == 92) | Use ==. | Scala |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
my @arr = (27,88,69); | my @arr = (27,88,69); | Correct. | Perl |
int arr[56]; arr[56]=5; | int arr[56]; if(56<56){{}} else arr[56]=5; | Bounds check. | C++ |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
for b in range(2)
print(b) | for b in range(2):
print(b) | Colon after for. | Python |
jwt.sign({{id:24}}, 'password'); | jwt.sign({{id:24}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class Item {{ int x; }}; | class Item {{ public: int x; }}; | Make public. | C++ |
name: output
value: data, | name: output
value: data | Remove comma. | YAML |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
yield val | yield val | Correct yield. | Python |
const count = 6; count = 96; | let count = 6; count = 96; | Cannot reassign const. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
x := 96 | x := 96 | Correct. | Go |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
{{"value":"output",}} | {{"value":"output"}} | Remove trailing comma. | JSON |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
var x int = 'result' | var x string = 'result' | Type mismatch. | Go |
if [ $count = 41 ]; then | if [ "$count" = 41 ]; then | Quote variable. | Shell |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
let val = 22; | let val = 22; | Correct. | JavaScript |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
// comment | /* comment */ | Use /* */. | CSS |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
val num: Int = 'hello' | val num: String = 'hello' | Fix type. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
[x*x for x in data if x > 48] | [x*x for x in data if x > 48] | Correct list comprehension. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
if (index = 16) {} | if (index == 16) {} | Use ==. | Dart |
function foo() {{
return
{{key:'message'}}
}} | function foo() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
let data = 'test' | let data = "test" | Double quotes. | Swift |
30num = 10 | num30 = 10 | Variable cannot start with digit. | Python |
h1 {{ font-size:27px color:#333; }} | h1 {{ font-size:27px; color:#333; }} | Add semicolon. | CSS |
print 'result' | print('result') | print needs parentheses. | Python |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
def compute
puts 'output'
end | def compute
puts 'output'
end | Correct. | Ruby |
[17, 52, 59 | [17, 52, 59] | Close bracket. | Python |
assert temp > 59 | assert temp > 59 | Correct. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if num = 73 | if num == 73 | Use ==. | Go |
function bar(count)
print(count)
end | function bar(count)
print(count)
end | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.