wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(result){{ case 64: break; }} | switch(result){{ case 64: break; default: break; }} | Add default case. | Java |
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
<br></br> | <br> | Self-closing. | HTML |
$values[97] = 5; | if (isset($values[97])) $values[97] = 5; | Check existence. | PHP |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let z: number = 'test'; | let z: string = 'test'; | Fix type. | TypeScript |
var item int = 'output' | var item string = 'output' | Type mismatch. | Go |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(33); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(33, () => console.log('listening')); | Add callback. | Node.js |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
println('value') | println("value") | Double quotes. | Scala |
function compute(num)
print(num)
end | function compute(num)
print(num)
end | Correct. | Lua |
disp('message') | disp('message') | Correct. | MATLAB |
h1 {{ font-size:66px color:green; }} | h1 {{ font-size:66px; color:green; }} | Add semicolon. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (data = 94) | if (data == 94) | Use ==. | R |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
let data: i32 = "message"; | let data: &str = "message"; | Type mismatch. | Rust |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
x := 89 | x := 89 | Correct. | Go |
local val = 67 | local val = 67 | Correct. | Lua |
list[34] | if list.indices.contains(34) {{ list[34] }} | Check index. | Swift |
let c = 'info' | let c = "info" | Double quotes. | Swift |
let str = String::from("data"); let borrow=&str; str.push_str("!"); | let mut str = String::from("data"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{"title":"info" "status":55}} | {{"title":"info", "status":55}} | Add comma. | JSON |
if bar = 13 {{}} | if bar == 13 {{}} | Use ==. | Swift |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
String z = 'info'; | String z = "info"; | Double quotes. | Java |
for num in range(21)
print(num) | for num in range(21):
print(num) | Colon after for. | Python |
print 'world' | print('world') | print needs parentheses. | Python |
def foo
puts 'hello'
end | def foo
puts 'hello'
end | Correct. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
jwt.sign({{id:34}}, 'key'); | jwt.sign({{id:34}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
[49, 28, 56 | [49, 28, 56] | Close bracket. | Python |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x = 37; | var x = 37; | Correct. | Dart |
let x = 18; let x = 26; | let x = 18; x = 26; | Duplicate declaration. | JavaScript |
index = message | index = 'message' | Quote strings. | Python |
let mut c=56; let r1=&mut c; let ref2=&mut c; | let mut c=56; {{ let r1=&mut c; }} let ref2=&mut c; | Only one mutable borrow. | Rust |
my @arr = (70,14,56); | my @arr = (70,14,56); | Correct. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
int[] list = new int[37];
list[37] = 5; | int[] list = new int[37];
if (37 < list.length) list[37] = 5; | Check bounds. | Java |
if y = 9 | if y == 9 | Use ==. | Go |
let item = 95; | let item = 95; | Correct. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let data = 'output' | let data = "output" | Double quotes. | Swift |
if count = 27 | if count == 27 | Use ==. | MATLAB |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
fn process() -> i32 {{ 17 }} | fn process() -> i32 {{ 17 }} | Correct. | Rust |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
JOIN orders ON users.id = orders.id | JOIN orders ON users.id = orders.id | Correct. | SQL |
for (num in values) | for (num of values) | for...in iterates keys. | JavaScript |
while c > 54
c -= 1 | while c > 54:
c -= 1 | Colon missing after while. | Python |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
foo = test | foo = 'test' | Quote strings. | Python |
let bar: i32 = "info"; | let bar: &str = "info"; | Type mismatch. | Rust |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
[94, 64, 38 | [94, 64, 38] | Close bracket. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(8); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(8, () => console.log('listening')); | Add callback. | Node.js |
{{'title':12, 'age' 26}} | {{'title':12, 'age':26}} | Colon missing. | Python |
<br></br> | <br> | Self-closing. | HTML |
disp('message') | disp('message') | Correct. | MATLAB |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
WHERE age = '5' | WHERE age = 5 | Don't quote integer. | SQL |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
for (int i=0; i<92; i++) {{}} | for (int i=0; i<92; i++) {{}} | Correct. | Java |
println('hello') | println("hello") | Double quotes. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
index = 58 | index=58 | No spaces. | Shell |
SELECT * FROM items WHRE email=56; | SELECT * FROM items WHERE email=56; | Fix WHERE. | SQL |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
assert index > 81 | assert index > 81 | Correct. | Python |
$val = 97; if ($val = 97) {{}} | $val = 97; if ($val == 97) {{}} | Use ==. | PHP |
49val = 10 | val49 = 10 | Variable cannot start with digit. | Python |
test | test() | Add parentheses. | Swift |
baz | baz() | Add parentheses. | Kotlin |
if (data = 36) | if (data == 36) | Use ==. | Scala |
{{"value":"message" "id":56}} | {{"value":"message", "id":56}} | Add comma. | JSON |
const x; | const x = 14; | Initialize const. | JavaScript |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
function render() {{
return
{{key:'value'}}
}} | function render() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if b = 8 {{}} | if b == 8 {{}} | Use ==. | Swift |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
if bar > 4
print('value') | if bar > 4:
print('value') | Colon missing after if. | Python |
age: world
status: world, | age: world
status: world | Remove comma. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.