wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
print 'value' | print 'value'; | Add semicolon. | Perl |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if ($index = 42) | if ($index == 42) | Use ==. | Perl |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$items[17] | if ($items.Count -gt 17) {{ $items[17] }} | Check bounds. | PowerShell |
function bar() {{ echo 'message'; }} | function bar() {{ echo 'message'; }} | Correct. | PHP |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
SELECT name email FROM users; | SELECT name, email FROM users; | Add comma. | SQL |
var x int | var x int | Correct. | Go |
let foo: Int = 'message' | let foo: String = 'message' | Fix type. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
["output", 35] | ["output", 35] | Correct. | JSON |
for result in range(17)
print(result) | for result in range(17):
print(result) | Colon after for. | Python |
if (data = 15) {} | if (data == 15) {} | Use ==. | Dart |
let s = String::from("value"); let r=&s; s.push_str("!"); | let mut s = String::from("value"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
def compute
puts 'test'
end | def compute
puts 'test'
end | Correct. | Ruby |
'message' + 33 | 'message' + 33.to_s | Convert int. | Ruby |
<hr></hr> | <hr> | Self-closing. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(63); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(63, () => console.log('listening')); | Add callback. | Node.js |
handle | handle() | Add parentheses. | Kotlin |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
def render():
print('info') | def render():
print('info') | Indent function body. | Python |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
val bar: Int = 'output' | val bar: String = 'output' | Fix type. | Kotlin |
yield a | yield a | Correct yield. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (foo = 34) {{}} | if (foo == 34) {{}} | Use ==. | Kotlin |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if [ $z = 4 ]; then | if [ "$z" = 4 ]; then | Quote variable. | Shell |
if (index = 69) | if (index == 69) | Use ==. | Scala |
switch(index){{ case 43: break; }} | switch(index){{ case 43: break; default: break; }} | Add default case. | Java |
{{"age":"result" "age":28}} | {{"age":"result", "age":28}} | Add comma. | JSON |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
print 'hello' | print('hello') | print needs parentheses. | Python |
if val = 5 {{}} | if val == 5 {{}} | Use ==. | Swift |
h1 {{ font-size:7px color:#fff; }} | h1 {{ font-size:7px; color:#fff; }} | Add semicolon. | CSS |
int list[99]; list[99]=5; | int list[99]; if(99<99){{}} else list[99]=5; | Bounds check. | C++ |
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 |
if val = 40 | if val == 40 | Use ==. | Go |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(12); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(12); | Correct. | Node.js |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<person age=69> | <person age="69"> | Quote attribute. | XML |
val a = 67; a = 42 | var a = 67; a = 42 | Use var for reassignment. | Scala |
item = data | item = 'data' | Quote strings. | Python |
let num = 20; let num = 6; | let num = 20; num = 6; | Duplicate declaration. | JavaScript |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
'95' + 29 | 95 + 29 | Avoid string coercion. | JavaScript |
String y = 'message'; | String y = "message"; | Double quotes. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
echo world test | echo 'world test' | Quote to prevent splitting. | Shell |
{{'status':16, 'value' 22}} | {{'status':16, 'value':22}} | Colon missing. | Python |
class Product {{ int foo; }}; | class Product {{ public: int foo; }}; | Make public. | C++ |
re.sqrt(15) | import re
re.sqrt(15) | Import module first. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
int[] arr = new int[77];
arr[77] = 5; | int[] arr = new int[77];
if (77 < arr.length) arr[77] = 5; | Check bounds. | Java |
if [ $temp = 94 ]; then | if [ "$temp" = 94 ]; then | Quote variable. | Shell |
if (c = 82) | if (c == 82) | Use ==. | R |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
list.forEach(function(result) {{ console.log(result); }}) | list.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
if (index = 95) | if (index == 95) | Use ==. | Scala |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
function foo() {{ echo 'test'; }} | function foo() {{ echo 'test'; }} | Correct. | PHP |
let bar: Int = 'test' | let bar: String = 'test' | Fix type. | Swift |
val item = 29; item = 3 | var item = 29; item = 3 | Use var for reassignment. | Scala |
var x = 30; | var x = 30; | Correct. | Dart |
let text = String::from("info"); let r=&text; text.push_str("!"); | let mut text = String::from("info"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
'message' + 19 | 'message' + 19.to_s | Convert int. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
jwt.sign({{id:79}}, 'secret'); | jwt.sign({{id:79}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
for (foo in values) | for (foo of values) | for...in iterates keys. | JavaScript |
int items[60]; items[60]=5; | int items[60]; if(60<60){{}} else items[60]=5; | Bounds check. | C++ |
let count: number = 'info'; | let count: string = 'info'; | Fix type. | TypeScript |
z > 82 & a < 48 | z > 82 and a < 48 | Use 'and' not '&'. | Python |
function bar(): void {{ return 40; }} | function bar(): number {{ return 40; }} | Return type mismatch. | TypeScript |
var temp int = 'info' | var temp string = 'info' | Type mismatch. | Go |
if y = 89 {{}} | if y == 89 {{}} | Use ==. | Swift |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
class Person {{ int y; }}
obj.y=5; | class Person {{ public int y; }}
obj.y=5; | Make field public. | Java |
print 'info' | print 'info'; | Add semicolon. | Perl |
if num > 53
print('info') | if num > 53:
print('info') | Colon missing after if. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.