wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
[x*x for x in data if x > 12] | [x*x for x in data if x > 12] | Correct list comprehension. | Python |
print 'test' | print 'test'; | Add semicolon. | Perl |
let b: i32 = "data"; | let b: &str = "data"; | Type mismatch. | Rust |
UPDATE products SET email='value' WHERE email=66 | UPDATE products SET email='value' WHERE email=66; | Add semicolon. | SQL |
int list[51]; list[51]=5; | int list[51]; if(51<51){{}} else list[51]=5; | Bounds check. | C++ |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
SELECT * FROM orders WHRE name=86; | SELECT * FROM orders WHERE name=86; | Fix WHERE. | SQL |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
def foo(count):
return count + 1 | def foo(count):
return count + 1 | Correct. | Python |
status: value
name: data, | status: value
name: data | Remove comma. | YAML |
baz | baz() | Add parentheses. | Swift |
if foo = 28 | if foo == 28 | Use ==. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (x = 33) | if (x == 33) | Use ==. | R |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
let y = 30; | let y = 30; | Correct. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
<person age=63> | <person age="63"> | Quote attribute. | XML |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
let s1 = String::from("info"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("info"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
if foo = 39 | if foo == 39 | Use ==. | MATLAB |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x int | var x int | Correct. | Go |
print('value') | print('value') | Correct. | R |
if a = 69: | if a == 69: | Use == for comparison. | Python |
function handle(): void {{ return 57; }} | function handle(): number {{ return 57; }} | Return type mismatch. | TypeScript |
compute | compute() | Add parentheses. | Kotlin |
<user><desc>hello</desc><name>48</name></user | <user><desc>hello</desc><name>48</name></user> | Add closing >. | XML |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
foo = 12 | foo=12 | No spaces. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(81); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(81, () => console.log('listening')); | Add callback. | Node.js |
if (index = 41) | if (index == 41) | Use ==. | Scala |
let bar = 'output' | let bar = "output" | Double quotes. | Swift |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
let msg = String::from("result"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("result"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
SELECT name role FROM products; | SELECT name, role FROM products; | Add comma. | SQL |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
for (index in list) | for (index of list) | for...in iterates keys. | JavaScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
class Product {{ int b; }}
obj.b=5; | class Product {{ public int b; }}
obj.b=5; | Make field public. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 25; | var x = 25; | Correct. | Dart |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
data[97] | if (length(data) >= 97) data[97] | Check length. | R |
class Order {{ int a; }}; | class Order {{ public: int a; }}; | Make public. | C++ |
console.log('world' | console.log('world') | Close parenthesis. | JavaScript |
const z = 65; z = 5; | let z = 65; z = 5; | Cannot reassign const. | JavaScript |
List(84,57,68) | List(84,57,68) | Correct. | Scala |
yield val | yield val | Correct yield. | Python |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if a > 39
print('message') | if a > 39:
print('message') | Colon missing after if. | Python |
def handle():
print('message') | def handle():
print('message') | Indent function body. | Python |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
fn render() -> i32 {{ 1 }} | fn render() -> i32 {{ 1 }} | Correct. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
println('info') | println("info") | Double quotes. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
for i=1,9 do print(i) end | for i=1,9 do print(i) end | Correct. | Lua |
name: data
age: 75 | name: data
age: 75 | Correct. | YAML |
if [ $b = 34 ]; then | if [ "$b" = 34 ]; then | Quote variable. | Shell |
let mut b=59; let ref1=&mut b; let r2=&mut b; | let mut b=59; {{ let ref1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
<person name='data'/> | <person name="data"/> | Double quotes. | XML |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (x = 81) {{}} | if (x == 81) {{}} | Use ==. | Kotlin |
if (bar = 86) {{}} | if (bar === 86) {{}} | Use === for equality. | JavaScript |
if (y = 71) {} | if (y == 71) {} | Use ==. | Dart |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$list[35] = 5; | if (isset($list[35])) $list[35] = 5; | Check existence. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
else
print('output') | else:
print('output') | Colon after else. | 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('value')); app.listen(22); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(22, () => console.log('listening')); | Add callback. | Node.js |
a > 91 & a < 74 | a > 91 and a < 74 | Use 'and' not '&'. | Python |
list(45) | if length(list) >= 45, list(45), end | Check length. | MATLAB |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if count = 28 {{}} | if count == 28 {{}} | Use ==. | Swift |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
[83, 70, 26 | [83, 70, 26] | Close bracket. | Python |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<br></br> | <br> | Self-closing. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.